requests.base
-
Declaration
interface
Auth
;Interface to provide user info and http headers requred for server auth.
-
Declaration
abstract string[string]
authHeaders
(stringdomain
);Create headers for authentication
-
Declaration
abstract string
userName
();Returns user name
-
Declaration
abstract string
password
();Returns user
password
-
-
Declaration
class
BasicAuthentication
: requests.base.Auth;Basic authentication. Adds Authorization: Basic header to request
Example:
import requests; void main() { rq = Request(); rq.authenticator = new BasicAuthentication("user", "passwd"); rs = rq.get("http://httpbin.org/basic-auth/user/passwd"); }
-
Declaration
this(string
username
, stringpassword
, string[]domains
= []);Constructor.
Parameters
string
username
username
string
password
password
string[]
domains
not used now
-
Declaration
string[string]
authHeaders
(stringdomain
);create Basic Auth header
-
Declaration
string
userName
();returns username
-
Declaration
string
password
();return user
password
-
Declaration
struct
PostFile
;Struct to send multiple files in POST request.
-
Declaration
string
fileName
;Path to the file to send.
-
Declaration
string
fieldName
;Name of the field (if empty - send file base name)
-
Declaration
string
contentType
;contentType
of the file if not empty
-
-
Declaration
interface
FiniteReadable
; -
Declaration
auto
formData
(stringname
, Filef
, string[string]parameters
= null);Helper to create form elements from File.
Parameters
string
name
name
of the field in formFile
f
opened std.stio.File to send to server
string[string]
parameters
optional
parameters
(most important are "filename" and "Content-Type") -
Declaration
auto
formData
(stringname
, ubyte[]b
, string[string]parameters
= null);Helper to create form elements from ubyte[].
Parameters
string
name
name
of the field in formubyte[]
b
data to send to server
string[string]
parameters
optional
parameters
(can be "filename" and "Content-Type") -
Declaration
class
FormDataBytes
: requests.base.FiniteReadable;Class to provide FiniteReadable from user-provided ubyte[]
-
Declaration
this(ubyte[]
data
);constructor from ubyte[]
-
-
Declaration
class
FormDataFile
: requests.base.FiniteReadable;Class to provide FiniteReadable from File
-
Declaration
this(File
file
);constructor from File object
-
-
Declaration
struct
MultipartForm
;This struct used to bulld POST's to forms. Each part have name and data. data is something that can be read-ed and have size. For example this can be string-like object (wrapped for reading) or opened File.
-
Declaration
class
RequestException
: object.Exception;General type exception from Request
-
Declaration
struct
ReceiveAsRange
;ReceiveAsRange
is InputRange used to supply client with data from response. Each popFront fetch next data portion.-
Declaration
package ubyte[] delegate()
read
;HTTP or FTP module set up delegate
read
() for reading next portion of data.
-
-
Declaration
class
Response
;Response
-
Declaration
package ushort
_code
;Server status code
-
Declaration
package Buffer!ubyte
_responseBody
;Response body
-
Declaration
package string[string]
_responseHeaders
;Response headers
-
Declaration
package URI
_uri
;Initial URI
-
Declaration
package URI
_finalURI
;Final URI. Can differ from uri() if request go through redirections.
-
Declaration
package ReceiveAsRange
_receiveAsRange
;stream range stored here
-
Declaration
package long
_contentReceived
;Length of received content
-
Declaration
package long
_contentLength
;Server-supplied content length (can be -1 when unknown)
-
Declaration
const string
toString
();string representation of response
-
Declaration
const string
format
(stringfmt
);format
response to string (hpPqsBTUS).Discussion
%h - remote hostname
%p - remote port
%P - remote path
%q - query parameters
%s - string representation
%B - received bytes
%T - resquest total time
%U - request uri()
%S - status code
-