CkHttpRequest C++ Class Reference
CkHttpRequest
Represents a complete HTTP request.
Properties
void get_Charset(CkString &str); void put_Charset(const char *charset);
Controls the character encoding used for HTTP request parameters for POST requests. The default value is "utf-8". The charset should match the charset expected by the form target.
void get_ContentType(CkString &str); void put_ContentType(const char *newVal);
To be documented soon...
void get_EntireHeader(CkString &str); void put_EntireHeader(const char *newVal);
To be documented soon...
void get_HttpVerb(CkString &str); void put_HttpVerb(const char *newVal);
To be documented soon...
void get_HttpVersion(CkString &str); void put_HttpVersion(const char *version);
The HTTP version in the request header. Defaults to "1.1".
void LastErrorHtml(CkString &str);
Error information in HTML format for the last method called.
void LastErrorText(CkString &str);
Error information in plain-text format for the last method called.
void LastErrorXml(CkString &str);
Error information in XML format for the last method called.
int get_NumHeaderFields(void);
Returns the number of request header fields.
int get_NumParams(void);
Returns the number of query parameters.
void get_Path(CkString &str); void put_Path(const char *path);
The path of the resource requested. A path of "/" indicates the default document for a domain.
bool get_SendCharset(void); void put_SendCharset(bool val);
Controls whether the charset is explicitly included in the content-type header field of the HTTP POST request.
bool get_Utf8(void) const; void put_Utf8(bool b);
When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.
Methods
bool AddBytesForUpload(const char * name, const char * remoteFileName, CkByteData & byteData);
Adds a file to an upload request where the contents of the file come from an in-memory byte array. To create a file upload request, call UseUpload and then call AddBytesForUpload, AddStringForUpload, or AddFileForUpload for each file to be uploaded.
name is an arbitrary name. (In HTML, it is the form field name of the input tag.)
remoteFileName is the name of the file to be created on the HTTP server.
byteData contains the contents (bytes) to be uploaded.
bool AddBytesForUpload2(const char * name, const char * remoteFileName, CkByteData & byteData, const char * contentType);
Same as AddBytesForUpload, but allows the Content-Type header field to be directly specified. (Otherwise, the Content-Type header is automatically determined based on the remoteFileName's file extension.)
bool AddFileForUpload(const char * name, const char * filePath);
Adds a file to an upload request. To create a file upload request, call UseUpload and then call AddFileForUpload, AddBytesForUpload, or AddStringForUpload for each file to be uploaded. This method does not read the file into memory. When the upload occurs, the data is streamed directly from the file, thus allowing for very large files to be uploaded without consuming large amounts of memory.
name is an arbitrary name. (In HTML, it is the form field name of the input tag.)
filePath is the path to an existing file in the local filesystem.
bool AddFileForUpload2(const char * name, const char * filePath, const char * contentType);
Same as AddFileForUpload, but allows the Content-Type header field to be directly specified. (Otherwise, the Content-Type header is automatically determined based on the file extension.)
name is an arbitrary name. (In HTML, it is the form field name of the input tag.)
filePath is the path to an existing file in the local filesystem.
void AddHeader(const char * name, const char * value);
Adds a request header to the HTTP request. If a header having the same field name is already present, this method replaces it. Adding Cookies to an HTTP Request
void AddParam(const char * name, const char * value);
Adds a request query parameter (name/value pair) to the HTTP request. The name and value strings passed to this method should not be URL encoded.
bool AddStringForUpload(const char * name, const char * filename, const char * strData, const char * charset);
Same as AddFileForUpload, but the upload data comes from an in-memory string instead of a file.
bool AddStringForUpload2(const char * name, const char * filename, const char * strData, const char * charset, const char * contentType);
Same as AddStringForUpload, but allows the Content-Type header field to be directly specified. (Otherwise, the Content-Type header is automatically determined based on the ARG2's file extension.)
void GenerateRequestText(CkString & outStr);
Returns the request text that would be sent if Http.SynchronousRequest was called. Returns true for success, false for failure.
bool GetHeaderField(const char * name, CkString & outStr);
Returns the value of a request header field. Returns true for success, false for failure.
bool GetHeaderName(int index, CkString & outStr);
Returns the Nth request header field name. Indexing begins at 0, and the number of request header fields is specified by the NumHeaderFields property. Returns true for success, false for failure.
bool GetHeaderValue(int index, CkString & outStr);
Returns the Nth request header field value. Indexing begins at 0, and the number of request header fields is specified by the NumHeaderFields property. Returns true for success, false for failure.
bool GetParam(const char * name, CkString & outStr);
Returns a request query parameter value by name. Returns true for success, false for failure.
bool GetParamName(int index, CkString & outStr);
Returns the Nth request query parameter field name. Indexing begins at 0, and the number of request query parameter fields is specified by the NumParams property. Returns true for success, false for failure.
bool GetParamValue(int index, CkString & outStr);
Returns the Nth request query parameter field value. Indexing begins at 0, and the number of request query parameter fields is specified by the NumParams property. Returns true for success, false for failure.
bool GetUrlEncodedParams(CkString & outStr);
To be documented soon. Returns true for success, false for failure.
bool LoadBodyFromBytes(CkByteData & byteData);
The HTTP protocol is such that all HTTP requests are MIME. For non-multipart requests, this method may be called to set the MIME body of the HTTP request to the exact contents of the byteData.
Note: A non-multipart HTTP request consists of (1) the HTTP start line, (2) MIME header fields, and (3) the MIME body. This method sets the MIME body.
bool LoadBodyFromFile(const char * filePath);
The HTTP protocol is such that all HTTP requests are MIME. For non-multipart requests, this method may be called to set the MIME body of the HTTP request to the exact contents of filePath.
Note: A non-multipart HTTP request consists of (1) the HTTP start line, (2) MIME header fields, and (3) the MIME body. This method sets the MIME body.
bool LoadBodyFromString(const char * bodyStr, const char * charset);
The HTTP protocol is such that all HTTP requests are MIME. For non-multipart requests, this method may be called to set the MIME body of the HTTP request to the exact contents of bodyStr.
Note: A non-multipart HTTP request consists of (1) the HTTP start line, (2) MIME header fields, and (3) the MIME body. This method sets the MIME body.
charset indicates the charset, such as "utf-8" or "iso-8859-1", to be used. The HTTP body will contain the bodyStr converted to this character encoding.
void RemoveAllParams();
Removes all request parameters.
void RemoveParam(const char * name);
Removes a single HTTP request parameter by name.
bool SaveLastError(const char * filename);
Saves the last error information to an XML formatted file.
void SetFromUrl(const char * url);
Parses a URL and sets the Path and query parameters (NumParams, GetParam, GetParamName, GetParamValue).
bool StreamBodyFromFile(const char * filename);
To be documented soon...
void UseGet();
Makes the HttpRequest a GET request.
void UseHead();
Makes the HttpRequest a HEAD request.
void UsePost();
Makes the HttpRequest a POST request that uses the "application/x-www-form-urlencoded" content type.
void UsePostMultipartForm();
Makes the HttpRequest a POST request that uses the "multipart/form-data" content type.
void UsePut();
Makes the HttpRequest a PUT request.
void UseUpload();
Makes the HttpRequest a POST request that uses the "multipart/form-data" content type. To create a file upload request, call UseUpload and then call AddFileForUpload for each file to be uploaded.
void UseUploadPut();
To be documented soon...
void UseXmlHttp(const char * xmlBody);
Makes the HttpRequest a POST request using the "application/xml" content type. The request body is set to the XML string passed to this method.
const char * charset();
Controls the character encoding used for HTTP request parameters for POST requests. The default value is "utf-8". The charset should match the charset expected by the form target. Returns a null on failure
const char * contentType();
To be documented soon...
const char * entireHeader();
To be documented soon...
const char * generateRequestText();
Returns the request text that would be sent if Http.SynchronousRequest was called. Returns a null on failure
const char * getHeaderField(const char * name);
Returns the value of a request header field. Returns a null on failure
const char * getHeaderName(int index);
Returns the Nth request header field name. Indexing begins at 0, and the number of request header fields is specified by the NumHeaderFields property. Returns a null on failure
const char * getHeaderValue(int index);
Returns the Nth request header field value. Indexing begins at 0, and the number of request header fields is specified by the NumHeaderFields property. Returns a null on failure
const char * getParam(const char * name);
Returns a request query parameter value by name. Returns a null on failure
const char * getParamName(int index);
Returns the Nth request query parameter field name. Indexing begins at 0, and the number of request query parameter fields is specified by the NumParams property. Returns a null on failure
const char * getParamValue(int index);
Returns the Nth request query parameter field value. Indexing begins at 0, and the number of request query parameter fields is specified by the NumParams property. Returns a null on failure
const char * getUrlEncodedParams();
To be documented soon. Returns a null on failure
const char * httpVerb();
To be documented soon...
const char * httpVersion();
The HTTP version in the request header. Defaults to "1.1". Returns a null on failure
const char * lastErrorHtml();
Error information in HTML format for the last method called.Returns a null on failure
const char * lastErrorText();
Error information in plain-text format for the last method called.Returns a null on failure
const char * lastErrorXml();
Error information in XML format for the last method called.Returns a null on failure
const char * path();
The path of the resource requested. A path of "/" indicates the default document for a domain. Returns a null on failure
|