Title: | Basic HTTP Request |
---|---|
Description: | HTTP Request protocols. Implements the GET, POST and multipart POST request. |
Authors: | Eryk Witold Wolski, Andreas Westfeld |
Maintainer: | Andreas Westfeld <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0.11 |
Built: | 2024-11-09 04:37:10 UTC |
Source: | https://github.com/cran/httpRequest |
Sends Get Request to HTTP Server
getToHost(host,path,referer,port=80)
getToHost(host,path,referer,port=80)
host |
The host to which to send the Request e. g.: www.spiegel.de, 127.0.0.1 |
path |
The path to the file eg. /cgi/getpasswords.pl?test=best or /index.html |
referer |
something like www.myhome.org |
port |
its 80 or 8080 most frequently |
It is a simple http client. So it does not take care of special chars e.g. whitspaces.
For details see e.g. perl HTTP::Request::Common documentation
andhttp://www.w3.org/Protocols/rfc1341/0_TableOfContents.html
The document which the server returns as a string.
E.W.Wolski [email protected]
postToHost, simplePostToHost
#check first if www.molgen.mpg.de is running. #port <- 80 #getToHost("www.molgen.mpg.de", # "/~wolski/test.php4?test=test1&test2=test2&test3=3", # "www.test.pl", port=port)
#check first if www.molgen.mpg.de is running. #port <- 80 #getToHost("www.molgen.mpg.de", # "/~wolski/test.php4?test=test1&test2=test2&test3=3", # "www.test.pl", port=port)
Sends Get Request to HTTP Server (experimental version of getToHost based on raw data type)
getToHost2(host,path,referer,port=80)
getToHost2(host,path,referer,port=80)
host |
The host to which to send the Request e. g.: www.spiegel.de, 127.0.0.1 |
path |
The path to the file eg. /cgi/getpasswords.pl?test=best or /index.html |
referer |
something like www.myhome.org |
port |
its 80 or 8080 most frequently |
It is a simple http client. So it does not take care of special chars e.g. whitspaces.
For details see e.g. perl HTTP::Request::Common documentation
andhttp://www.w3.org/Protocols/rfc1341/0_TableOfContents.html
The document which the server returns as a string.
E.W.Wolski [email protected]
getToHost
#check first if www.molgen.mpg.de is running. #port <- 80 #getToHost2("www.molgen.mpg.de", # "/~wolski/test.php4?test=test1&test2=test2&test3=3", # "www.test.pl", port=port)
#check first if www.molgen.mpg.de is running. #port <- 80 #getToHost2("www.molgen.mpg.de", # "/~wolski/test.php4?test=test1&test2=test2&test3=3", # "www.test.pl", port=port)
Sends Multiform Post Request to HTTP Server
postToHost(host, path, data.to.send, referer, port=80, ua, accept, accept.language, accept.encoding, accept.charset, contenttype, cookie)
postToHost(host, path, data.to.send, referer, port=80, ua, accept, accept.language, accept.encoding, accept.charset, contenttype, cookie)
host |
The host to which to send the Request e. g.: www.spiegel.de, 127.0.0.1 |
path |
The path to the file e. g. /cgi/getpasswords.pl or /index.html, default "/" |
data.to.send |
is a list of name value pairs e. g. list(name=value, name1=value1, name2=value2). The value may be a list("filename"=X, "object"=Y), where Y is a vector of type raw and X is a name to be posted as the filename of Y. |
referer |
something like www.myhome.org, default: NULL (not present in header) |
port |
port to connect to, default 80 |
ua |
Identifier of the user agent, default "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.5) Gecko/20070719 Iceweasel/2.0.0.5 (Debian-2.0.0.5-2)" |
accept |
document types that are accepted by the client, default: |
accept.language |
languages that are preferred by the client, default: "de,de-de;q=0.8,en-us;q=0.5,en;q=0.3" |
accept.encoding |
compressions that are accepted by the client, default: "gzip,deflate" |
accept.charset |
charset accepted by the client, default: "ISO-8859-1,utf-8;q=0.7,*;q=0.7" |
contenttype |
type of data that is sent to the server, default: "application/octet-stream" |
cookie |
e. g., "SessionID=1008XVG0F1F5D8H94294967295", default: NULL (not present in header) |
It is a simple http client. So it does not take care of special chars e.g. whitspaces.
For details see e.g. perl HTTP::Request::Common documentation
andhttp://www.w3.org/Protocols/rfc1341/0_TableOfContents.html
document which the server returns.
E.W.Wolski [email protected], Andreas Westfeld [email protected]
getToHost, simplePostToHost
#to test uncomment. First check that the host is running. #port <- 80 #test2 <- list( # "fruit"="apple", # "dat_defs"="20021204/F113213.dat", # "myimage"=list( # "filename"="myimage.raw", # "object"=as.raw(as.vector(mymatrix)) # ), # "upsa"="test" #) #postToHost("www.molgen.mpg.de", "/~wolski/test.php4", test2, # referer="www.test.de", port=port)
#to test uncomment. First check that the host is running. #port <- 80 #test2 <- list( # "fruit"="apple", # "dat_defs"="20021204/F113213.dat", # "myimage"=list( # "filename"="myimage.raw", # "object"=as.raw(as.vector(mymatrix)) # ), # "upsa"="test" #) #postToHost("www.molgen.mpg.de", "/~wolski/test.php4", test2, # referer="www.test.de", port=port)
Sends Post Request to HTTP Server
simplePostToHost(host, path, datatosend, referer, contenttype, port=80, maxlen=131063L)
simplePostToHost(host, path, datatosend, referer, contenttype, port=80, maxlen=131063L)
host |
The host to which to send the Request eg.: www.spiegel.de, localhost |
path |
The path to the file eg. ‘/cgi-bin/paramlist.cgi’ or ‘/index.html’ |
datatosend |
key value pairs pairs separated by \& |
referer |
something like www.myhome.org |
contenttype |
default: application/x-www-form-urlencoded |
port |
its 80 or 8080 most frequently |
maxlen |
maximum blocksize read at once |
It is a simple http client. So it does not take care of special chars e.g. whitspaces.
For details see e.g. perl HTTP::Request::Common documentation
andhttp://www.w3.org/Protocols/rfc1341/0_TableOfContents.html
The output is gathered in several blocks, if necessary. The
parameter maxlen is used to determine the last data block by
its length. The first block with less than maxlen bytes is
considered the last one.
The document which the server returns as a string.
E.W.Wolski [email protected], Andreas Westfeld
getToHost, postToHost
host <- "api.scb.se" path <- "/OV0104/v1/doris/en/ssd" data <- '{"format":"json"}' simplePostToHost(host, path, data, contenttype="text/json")
host <- "api.scb.se" path <- "/OV0104/v1/doris/en/ssd" data <- '{"format":"json"}' simplePostToHost(host, path, data, contenttype="text/json")