本文整理汇总了C++中HttpHeader类的典型用法代码示例。如果您正苦于以下问题:C++ HttpHeader类的具体用法?C++ HttpHeader怎么用?C++ HttpHeader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HttpHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
HttpHeader HttpHeader::Builder::build() const {
std::string headerStr;
switch (m_requestType) {
case eRequestType::HTTP_REQUEST_GET: {
headerStr += "GET ";
headerStr += m_requestPath;
headerStr += " HTTP/1.1\r\n";
break;
}
case eRequestType::HTTP_REQUEST_POST: {
headerStr += "POST ";
headerStr += m_requestPath;
headerStr += " HTTP/1.1\r\n";
break;
}
case eRequestType::HTTP_RESPONSE: {
headerStr += "HTTP/1.1 ";
headerStr += StatusString(m_statusCode);
headerStr += "\r\n";
break;
}
case eRequestType::UNKNOWN: {
return HttpHeader();
}
}
headerStr += Joiner().on("\r\n").join(m_headers.begin(), m_headers.end());
headerStr += "\r\n\r\n";
HttpHeader rVal;
rVal.parsePartial(core::memory::ConstBlob((u8 *) headerStr.c_str(), headerStr.length()));
return rVal;
}
示例2: check
bool ETagUrlChecker::check(HttpHeader& header, Url&url) {
if (header.getEtag() == "")
return false;
if (header.getEtag() == url.getEtag())
return false;
return true;
}
示例3: SendGetRequest
void fcyNet::SendGetRequest(Client* pClient, const string& Host, const string& Path)
{
// 创建GET请求
string tRequestGet = "GET ";
tRequestGet += Path;
tRequestGet += " HTTP/1.1\r\n";
// 发送GET请求
pClient->Send((fcData)&tRequestGet[0], tRequestGet.length());
// 创建头
HttpHeader tHeader;
tHeader["Host"] = Host;
tHeader["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
tHeader["Accept-Language"] = "zh-cn,zh;q=0.5";
tHeader["Accept-Encoding"] = "deflate;q=1.0,gzip;q=0.7";
tHeader["Accept-Charset"] = "GB2312,utf-8;q=0.7,*;q=0.7";
// tHeader["Connection"] = "keep-alive";
// tHeader["Keep-Alive"] = "300";
tHeader["Connection"] = "close";
tHeader["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)";
tHeader["Cache-Control"] = "no-cache";
tHeader["Pragma"] = "no-cache";
// 发送头
tHeader.Send(pClient);
}
示例4: parseMultiPart
void RequestParameters::parseMultiPart(const MultiPart & multiPart)
{
QList<QPair<QString, QVariant >> parameters;
for (const Part & part : multiPart.getParts())
{
HttpHeader contentDisposition = part.getHeader(http::ContentDisposition);
HttpHeaderElement element = contentDisposition.getElement();
if (element.getName()=="form-data")
{
QString name = element.getParameter("name");
if (part.hasHeader(http::ContentType))
{
UploadedFile uploadedFile;
uploadedFile.setContent(part.getContent());
if (element.isSet("filename"))
{
uploadedFile.setFilename(element.getParameter("filename"));
}
parameters << QPair<QString, QVariant>(name, uploadedFile.toQVariant());
}
else
{
parameters << QPair<QString, QVariant>(name, QString(part.getContent()));
}
}
}
parseList(parameters);
}
示例5: HttpRequest
HttpRequest HttpRequest::Builder::build() const {
const HttpHeader header = m_header.build();
if (header.getRequestType() == HttpHeader::eRequestType::HTTP_REQUEST_GET) {
ASSERT(m_body.size() == 0);
}
return HttpRequest(header, m_body);
}
示例6: set_headers
YETI_Result HttpEntity::set_headers(const HttpHeaders & headers)
{
HttpHeader * header;
header = headers.get_header(YETI_HTTP_HEADER_CONTENT_LENGTH);
if (header != NULL) {
m_content_length_is_known_ = true;
YETI_LargeSize length;
if (YETI_SUCCEEDED(header->get_value().to_integer64(length))) {
m_content_length_ = length;
} else {
m_content_length_ = 0;
}
}
header = headers.get_header(YETI_HTTP_HEADER_CONTENT_TYPE);
if (header != NULL) {
m_content_type_ = header->get_value();
}
header = headers.get_header(YETI_HTTP_HEADER_CONTENT_ENCODING);
if (header != NULL) {
m_content_encoding_ = header->get_value();
}
header = headers.get_header(YETI_HTTP_HEADER_TRANSFER_ENCODING);
if (header != NULL) {
m_transfer_encoding_ = header->get_value();
}
return YETI_SUCCESS;
}
示例7: get_header
const String * HttpHeaders::get_header_value(const char * name) const
{
HttpHeader * header = get_header(name);
if (header == NULL) {
return NULL;
} else {
return &header->get_value();
}
}
示例8: testGetWebPage
void testGetWebPage(Url&url) {
HttpClient client;
HttpHeader httpheader;
HttpContent httpcontent;
client.requestWebPage(url, httpheader, httpcontent);
//string header;
//client.requestHeader(url,header);
//cout<<header<<endl;
cout << httpheader.getHeaderStr() << endl;
}
示例9: parseHeader
void HttpRequest::parseHeader(const HttpHeader& header) {
addHeader(header);
QString headerName = header.getName();
QString value = header.getValue();
if (headerName==http::Host) {
url.setAuthority(value);
} else if (headerName==http::Cookie) {
cookies.parse(value);
} else if (headerName==http::ContentType) {
contentType.parse(value);
}
}
示例10: AppLog
void Chatting::OnTransactionReadyToRead(
Tizen::Net::Http::HttpSession& httpSession,
Tizen::Net::Http::HttpTransaction& httpTransaction,
int availableBodyLen) {
AppLog("OnTransactionReadyToRead");
HttpResponse* pHttpResponse = httpTransaction.GetResponse();
if (pHttpResponse->GetHttpStatusCode() == HTTP_STATUS_OK) {
HttpHeader* pHttpHeader = pHttpResponse->GetHeader();
if (pHttpHeader != null) {
String* tempHeaderString = pHttpHeader->GetRawHeaderN();
ByteBuffer* pBuffer = pHttpResponse->ReadBodyN();
AppLog((const char*)pBuffer->GetPointer());
String str((const char*) (pBuffer->GetPointer()));
// IJsonValue* pJson = JsonParser::ParseN(*pBuffer);
//
// JsonObject *pObject = static_cast<JsonObject*>(pJson);
//
// JsonString *userName = new JsonString("username");
// IJsonValue *pValName = null;
//
// JsonString *dates = new JsonString("date");
// IJsonValue *pValDate = null;
//
//
// pObject->GetValue(userName, pValName);
// pObject->GetValue(dates,pValDate);
//
//
// JsonString* pName = static_cast<JsonString*>(pValName);
// JsonString* pDate= static_cast<JsonString*>(pValDate);
//
// String text(L"이름: ");
// text.Append(*pName);
// text.Append("\n날짜: ");
// text.Append(*pDate);
// String text(str);
// text.Append(availableBodyLen);
// __pEditArea->SetText(text);
Draw();
delete tempHeaderString;
delete pBuffer;
}
}
}
示例11: requestHeader
int HttpClient::requestHeader(Url &url, HttpHeader &header) {
string headStr;
int ret = requestHeader(url, headStr);
header.setHeaderStr(headStr);
return ret;
}
示例12: parseHeader
void HttpProtocol::parseHeader(string& str,HttpHeader& http)
{
int i=0;
vector<string> p;
split(str,":",p);
http.set(p[0],p[1]);
}
示例13:
void
UserProfileForm::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool rs)
{
HttpResponse* pHttpResponse = httpTransaction.GetResponse();
if(pHttpResponse == null)
return;
HttpHeader* pHttpHeader = pHttpResponse->GetHeader();
if(pHttpHeader != null)
{
String* tempHeaderString = pHttpHeader->GetRawHeaderN();
AppLog("HeaderString=%ls\n",tempHeaderString->GetPointer());
}
AppLog("OnTransactionHeaderCompleted\n");
}
示例14: while
void
HttpResponse::VisitHeaders (HttpHeaderVisitor visitor, void *context)
{
HttpHeader *header;
VERIFY_MAIN_THREAD;
if (headers == NULL)
return;
header = (HttpHeader *) headers->First ();
while (header != NULL) {
visitor (context, header->GetHeader (), header->GetValue ());
header = (HttpHeader *) header->next;
}
}
示例15: Server
static void Server(String r)
{
TcpSocket server;
if(server.Listen(4000, 10)) {
TcpSocket socket;
LOG("Waiting...");
bool b = socket.Accept(server);
if(b) {
LOG("Connection accepted");
HttpHeader http;
http.Read(socket);
socket.Put(r);
socket.Close();
}
}
}