http 投稿を作成し、RCurl を使用してヘッダー情報を取得しようとしていますが、奇妙な動作が見られます。
セッション情報:
> curlVersion()$version
[1] "7.24.0"
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RCurl_1.95-4.1 bitops_1.0-6
私の仕事のAPIに投稿する奇妙な動作を最初に見ましたが、確かに別のWebサイトを試してみましたが、同じ動作をしています。これはうまくいきます:
> response <- postForm("http://posttestserver.com/post.php", stuff="Other stuff")
> response
[1] "Successfully dumped 1 post variables.\nView it at http://www.posttestserver.com/data/2013/10/04/{REDACTED}\nPost body was 0 chars long."
attr(,"Content-Type")
"text/html"
しかし、ヘッダー情報も取得したいと思います。ここからが楽しみの始まりです。
> h <- basicHeaderGatherer()
> response <- postForm("http://posttestserver.com/post.php", stuff="Other stuff", .opts=curlOptions(headerfunction=h$update))
Successfully dumped 1 post variables.
View it at http://www.posttestserver.com/data/2013/10/04/{REDACTED}
Post body was 0 chars long.>
> response
NULL
> h$value()
Date Server Access-Control-Allow-Origin Vary Content-Length Content-Type status
"Fri, 04 Oct 2013 18:50:14 GMT" "Apache" "*" "Accept-Encoding" "140" "text/html" "200"
statusMessage
"OK"
応答の色 (「正常にダンプされた 1... など」) が灰色になり、要求していないときに出力され、入力シェブロンがインデントされます。応答変数は NULL ですが、ヘッダーは正常に見えます。そして、次の行があります (verbose=TRUE を追加):
response <- postForm("http://posttestserver.com/post.php", stuff="Other stuff", .opts=curlOptions(headerfunction=h$update, verbose=TRUE))
R をハングアップさせるだけです。
何が起こっているのか少しもわかりません。何か助けや方向性があれば教えていただければ幸いです。