我正在尝试使用httr::POST
将Rson发送到R中的bosun。
set_config(verbose())
已启用,我看到标题:Expect: 100-continue
可能会触发码头错误。
命令是:
response <- httr::POST(url = "http://192.168.65.1:8070/api/put?details",
body = json_str,
add_headers("Content-Type" = "application/json; charset=UTF-8"))
详细说明:
-> POST http://192.168.65.1:8070/api/put?details HTTP/1.1
-> User-Agent: curl/7.35.0 Rcurl/1.96.0 httr/0.6.0
-> Host: 192.168.65.1:8070
-> Accept: */*
-> Accept-Encoding: gzip
-> Proxy-Connection: Keep-Alive
-> Content-Type: application/json; charset=UTF-8
-> Content-Length: 1
-> Expect: 100-continue
如何禁用标题Expect: 100-continue
?
这是我的sessionInfo()
:
R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=C LC_COLLATE=C
[5] LC_MONETARY=C LC_MESSAGES=C LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RJSONIO_1.3-0 httr_0.6.0 RCurl_1.96-0
loaded via a namespace (and not attached):
[1] bitops_1.0-6 stringr_0.6.2 tools_3.1.2
答案 0 :(得分:3)
要禁用Expect标头,只需将其设置为空字符串即可。添加
add_headers("Expect"="")
致POST
来电