Skip to content

Instantly share code, notes, and snippets.

@netskink
Last active October 31, 2017 13:39
Show Gist options
  • Save netskink/eb2cb9d105f5f2ba9c33ad4b0636f1af to your computer and use it in GitHub Desktop.
Save netskink/eb2cb9d105f5f2ba9c33ad4b0636f1af to your computer and use it in GitHub Desktop.
R sample1
test from R
T 192.168.1.4:41772 -> 107.170.47.130:80 [AP]
POST /post.php HTTP/1.1.
Host: www.posttestserver.com.
User-Agent: libcurl/7.52.1 r-curl/3.0 httr/1.3.1.
Accept-Encoding: gzip, deflate.
Accept: application/json, text/xml, application/xml, */*.
Content-Type: application/octet-stream.
Content-Length: 7.
.
1
2
3
4
T 107.170.47.130:80 -> 192.168.1.4:41772 [AP]
HTTP/1.1 200 OK.
Date: Tue, 31 Oct 2017 13:16:54 GMT.
Server: Apache/2.4.18 (Ubuntu).
Access-Control-Allow-Origin: *.
Vary: Accept-Encoding.
Content-Encoding: gzip.
Content-Length: 131.
Content-Type: text/html; charset=UTF-8.
.
............A
. .@.}N1'.....C.B.{.S*.........y....".......#..E.N.$.e..>.;$...S.O..;..,*|.|`(;E..fc.d.9K....r..s...^..c..x..........
Successfully dumped 0 post variables.
View it at http://www.posttestserver.com/data/2017/10/31/13.16.542133505421
No Post body.
Time: Tue, 31 Oct 17 13:16:54 +0000
Source ip: 174.194.28.54
Headers (Some may be inserted by server)
HTTP_HOST = www.posttestserver.com
HTTP_USER_AGENT = libcurl/7.52.1 r-curl/3.0 httr/1.3.1
HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_ACCEPT = application/json, text/xml, application/xml, */*
CONTENT_TYPE = application/octet-stream
CONTENT_LENGTH = 7
REMOTE_ADDR = 174.194.28.54
DOCUMENT_ROOT = /var/www/html
REQUEST_SCHEME = http
CONTEXT_PREFIX =
CONTEXT_DOCUMENT_ROOT = /var/www/html
REMOTE_PORT = 6570
GATEWAY_INTERFACE = CGI/1.1
REQUEST_METHOD = POST
QUERY_STRING =
REQUEST_URI = /post.php
PHP_SELF = /post.php
REQUEST_TIME_FLOAT = 1509455814.872
REQUEST_TIME = 1509455814
No Post Params.
Empty post body.
Upload contains PUT data:
1
2
3
4
# httr demo
library(httr)
# test of POST
my_url = "http://www.posttestserver.com/post.php"
beta = list (
aKey = 100,
anotherKey = -1,
aStringKey = "aValue"
)
mybody=list(
file = c(c("1","2","3","4"), filename="stdin.bin",content_type="applicaiton/octet-stream"),
beta=jsonlite::toJSON(beta,auto_unbox = TRUE)
)
# this actually works, but its treated as post data and not a file
resp = POST( my_url,
body = c("1","2","3","4"),
content_type("application/octet-stream"),
encode = "multipart")
# this shows its visible at
# http://www.posttestserver.com/data/2017/10/23/19.24.01560529599
cat(content(resp,"text"),"\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment