Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

httr disable "Expect: 100-continue"

Tags:

r

I am trying to send a json to bosun in R with httr::POST.

The set_config(verbose()) is enabled and I saw the header: Expect: 100-continue which might trigger a bug of jetty.

The command is:

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"))

The verbose shows:

-> 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

How should I disable the header Expect: 100-continue?

Here is my 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  
like image 937
wush978 Avatar asked Nov 19 '25 03:11

wush978


1 Answers

To disable the Expect header, you just set it to an empty string. Add

add_headers("Expect"="")

To your POST call

like image 50
MrFlick Avatar answered Nov 21 '25 18:11

MrFlick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!