-
Notifications
You must be signed in to change notification settings - Fork 1
mro web client
Do Nhat Minh edited this page May 4, 2013
·
5 revisions
(use-modules (mro web client))
Scheme Procedure: (http-get uri . args)
This function wraps around the GNU Guile's http-get procedure to provide automatic redirection. Connects to the server corresponding to uri and make the appropriate GET request, if the reponse has code 301 or 302, and also has a location header, automatically follow the new location, otherwise, it behaves just like GNU Guile's http-get. Returns two values: the response read from the server, and the response body as a string, bytevector, #f value, or as a port (if streaming? is true). Keyword arguments: #:body #f If body is not #f, a message body will also be sent with the HTTP request. If body is a string, it is encoded according to the content-type in headers, defaulting to UTF-8. Otherwise body should be a bytevector, or #f for no body. Although a message body may be sent with any request, usually only POST and PUT requests have bodies. #:port (open-socket-for-uri uri) If you already have a port open, pass it as port. Otherwise, a connection will be opened to the server corresponding to uri. #:version '(1 . 1) #:keep-alive? #f Unless keep-alive? is true, the port will be closed after the full response body has been read. #:headers '() Any extra headers in the alist headers will be added to the request. #:decode-body? #t If decode-body? is true, as is the default, the body of the response will be decoded to string, if it is a textual content-type. Otherwise, it will be returned as a bytevector. #:streaming? #f However, if streaming? is true, instead of eagerly reading the response body from the server, this function only reads off the headers. The response body will be returned as a port on which the data may be read.