本文整理汇总了C++中HttpConnection::setRequestHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpConnection::setRequestHeader方法的具体用法?C++ HttpConnection::setRequestHeader怎么用?C++ HttpConnection::setRequestHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpConnection
的用法示例。
在下文中一共展示了HttpConnection::setRequestHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setRequestHeaders
void HttpUploader::setRequestHeaders(const StringBuffer& luid, HttpConnection& httpConnection, InputStream& inputStream) {
StringBuffer dataSize;
int totalSize = inputStream.getTotalSize();
LOG.debug("[%s]: input stream size is %i", __FUNCTION__, totalSize);
LOG.debug("[%s]: totalDataToUpload size is %i", __FUNCTION__, totalDataToUpload);
if (totalDataToUpload > 0) {
totalSize = totalDataToUpload;
}
dataSize.sprintf("%d", totalSize);
httpConnection.setRequestHeader(HTTP_HEADER_ACCEPT, "*/*");
httpConnection.setRequestHeader(HTTP_HEADER_CONTENT_TYPE, "application/octet-stream");
// set transfer enconding to chunked
//httpConnection.setRequestHeader(HTTP_HEADER_TRANSFER_ENCODING, "chunked");
// set Funambol mandatory custom headers
httpConnection.setRequestHeader(HTTP_HEADER_X_FUNAMBOL_FILE_SIZE, dataSize);
httpConnection.setRequestHeader(HTTP_HEADER_X_FUNAMBOL_DEVICE_ID, deviceID);
httpConnection.setRequestHeader(HTTP_HEADER_X_FUNAMBOL_LUID, luid);
if (partialUploadedData > 0) {
StringBuffer s;
s.sprintf("bytes %d-%d/%d", partialUploadedData, totalSize-1, totalSize);
httpConnection.setRequestHeader(HTTP_HEADER_CONTENT_RANGE, s.c_str());
}
}
示例2: testGET
/**
* Tests a GET on a specific URL, prints the response.
*/
void testGET(const URL& testURL)
{
LOG.debug("test GET on %s", testURL.fullURL);
int ret = httpConnection.open(testURL, HttpConnection::MethodGet);
LOG.debug("open, ret = %d", ret);
BufferInputStream inputStream("");
StringOutputStream outputStream;
httpConnection.setRequestHeader(HTTP_HEADER_ACCEPT, "*/*");
httpConnection.setRequestHeader(HTTP_HEADER_CONTENT_LENGTH, 0);
ret = httpConnection.request(inputStream, outputStream);
LOG.debug("request, ret = %d", ret);
LOG.debug("response = \n%s", outputStream.getString().c_str());
httpConnection.close();
}
示例3: startDownload
void startDownload() {
if(0 == strcmp(URL, ""))
{
printf("No url provided, \nsee source code for \ninformation on how \nto use this example");
return;
}
printf("Downloading from %s\n", URL);
//in case of re-download
mHttp.close();
mHttp.create(URL, HTTP_GET);
if(mLastModified.length() > 0)
mHttp.setRequestHeader("If-Modified-Since", mLastModified.c_str());
mHttp.finish();
}