Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
67 lines (54 loc) · 1.49 KB

File metadata and controls

67 lines (54 loc) · 1.49 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// HttpPdu.cpp
// http_msg_server
//
// Created by jianqing.du on 13-9-29.
// Copyright (c) 2013年 ziteng. All rights reserved.
//
#include "HttpParserWrapper.h"
#include "http_parser.h"
CHttpParserWrapper* CHttpParserWrapper::m_instance = NULL;
CHttpParserWrapper::CHttpParserWrapper()
{
}
CHttpParserWrapper* CHttpParserWrapper::GetInstance()
{
if (!m_instance) {
m_instance = new CHttpParserWrapper();
}
return m_instance;
}
void CHttpParserWrapper::ParseHttpContent(const char* buf, uint32_t len)
{
http_parser_init(&m_http_parser, HTTP_REQUEST);
memset(&m_settings, 0, sizeof(m_settings));
m_settings.on_url = OnUrl;
m_settings.on_headers_complete = OnHeadersComplete;
m_settings.on_body = OnBody;
m_settings.on_message_complete = OnMessageComplete;
m_read_all = false;
m_total_length = 0;
m_url.clear();
m_body_content.clear();
http_parser_execute(&m_http_parser, &m_settings, buf, len);
}
int CHttpParserWrapper::OnUrl(http_parser* parser, const char *at, size_t length)
{
m_instance->SetUrl(at, length);
return 0;
}
int CHttpParserWrapper::OnHeadersComplete (http_parser* parser)
{
m_instance->SetTotalLength(parser->nread + (uint32_t)parser->content_length);
return 0;
}
int CHttpParserWrapper::OnBody (http_parser* parser, const char *at, size_t length)
{
m_instance->SetBodyContent(at, length);
return 0;
}
int CHttpParserWrapper::OnMessageComplete (http_parser* parser)
{
m_instance->SetReadAll();
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.