The OpenD Programming Language

HTTPRequest

Request. Configurable parameters: method - string, method to use (GET, POST, ...) headers - stringstring, add any additional headers you'd like to send. authenticator - class Auth, class to send auth headers. keepAlive - bool, set true for keepAlive requests. default true. maxRedirects - uint, maximum number of redirects. default 10. maxHeadersLength - size_t, maximum length of server response headers. default = 32KB. maxContentLength - size_t, maximun content length. delault - 0 = unlimited. bufferSize - size_t, send and receive buffer size. default = 16KB. verbosity - uint, level of verbosity(0 - nothing, 1 - headers, 2 - headers and body progress). default = 0. proxy - string, set proxy url if needed. default - null. cookie - Tuple Cookie, Read/Write cookie You can get cookie setted by server, or set cookies before doing request. timeout - Duration, Set timeout value for connect/receive/send.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

addHeaders
void addHeaders(string[string] headers)

Add headers to request

close_connection_if_not_keepalive
void close_connection_if_not_keepalive(NetworkStream _stream)

If we do not want keepalive request, or server signalled to close connection, then close it

exec
deprecated HTTPResponse exec(string url, MultipartForm sources)

Send multipart for request. You would like to use this method for sending large portions of mixed data or uploading files to forms. Content of the posted form consist of sources. Each source have at least name and value (can be string-like object or opened file, see more docs for MultipartForm struct)

exec
deprecated HTTPResponse exec(string url, R content, string contentType)

POST/PUT/... data from some string(with Content-Length), or from range of strings/bytes (use Transfer-Encoding: chunked). When rank 1 (flat array) used as content it must have length. In that case "content" will be sent directly to network, and Content-Length headers will be added. If you are goung to send some range and do not know length at the moment when you start to send request, then you can send chunks of chars or ubyte. Try not to send too short chunks as this will put additional load on client and server. Chunks of length 2048 or 4096 are ok.

exec
deprecated HTTPResponse exec(string url, QueryParam[] params)

Send request with parameters. If used for POST or PUT requests then application/x-www-form-urlencoded used. Request parameters will be encoded into request string or placed in request body for POST/PUT requests.

exec
deprecated HTTPResponse exec(string url, PostFile[] files)

WRAPPERS

exec
deprecated HTTPResponse exec(string url, string[string] params)

exec request with parameters when you can use dictionary (when you have no duplicates in parameter names) Consider switch to exec(url, QueryParams) as it more generic and clear.

get
deprecated HTTPResponse get(A args)

GET request. Simple wrapper over exec!"GET"

post
deprecated HTTPResponse post(string uri, A args)

POST request. Simple wrapper over exec!"POST"

removeHeaders
void removeHeaders(string[] headers)

Remove headers from request

Meta