Returns a new generic HTTP request object
Agent
Name | Type | Description |
---|---|---|
verb | String |
The HTTP method required (eg. OPTIONS)
|
url | String |
The URL to which the HTTP request will be made
|
headers | Table |
Optional table of additional HTTP headers
|
body | String or blob |
The body of the HTTP request, or an empty string
|
An httprequest object
This method returns an httprequest object primed to make an HTTP/1.1 request with a custom method (verb) to the specified URL. The request isn’t issued until either sendsync() or sendasync() is called on the returned httprequest object.
Note This should not be used to make HEAD requests as this does not function correctly under Squirrel. For more information and a workaround, please see this Knowledgebase article.
The URL must start with "http://"
or "https://"
— ie. it must include the colon and the double-slash.
The headers can be any supported by HTTP, for instance:
{ "Content-Type" : "text/xml" }
Note Headers are specified without the colon.
The request body can be any string, but most servers will expect its content-type to be as described by the Content-Type header. If no request body is needed, use an empty string, ""
.
The most common HTTP request methods are provided by the convenience methods http.get(), http.put(), http.post() and http.httpdelete(). Use http.request() if you need an HTTP method other than those prepared for you — if you are accessing services using WebDAV or similar extensions to HTTP, for instance.
Generic wrapper function to create an execute a generic HTTP request.