- with-input-from-request uri-or-request writer readerprocedure
Convenience interface for making a request and reading the response body from the current input port. The reader argument is a thunk called with the response body bound to current-input-port.
The uri-or-request argument may be a URI string, a uri-common URI object, or an intarweb request object.
The writer argument controls the request body:
- #f performs a GET when uri-or-request is not already a request object
- A string is sent as the request body
- An alist is form-url-encoded and sent as application/x-www-form-urlencoded
- A procedure writes the request body to current-output-port
Returns three values: the reader result, the request URI, and the intarweb response object.
(with-input-from-request "https://httpbin.org/get" #f read-string) (with-input-from-request "https://httpbin.org/post" '((name . "Ada") (language . "Scheme")) read-string)