{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 43,
"in/out_function : Constructor http_response::http_response(void)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 1, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 44,
"in/out_function : Constructor http_response::http_response(std::string header) : "
"header(%s)", header.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 2, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 45,
"in/out_function : Destructor http_response::~http_response(void)");
}
/*------ DEBUG LOG END ------*/
*
* @return HTTP version
*/
-std::string http_response::http_version()
+std::string http_response::http_version() const
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 46,
"in_function : std::string http_response::http_version(void)");
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 47,
"out_function : std::string http_response::http_version(void) : "
"return(%s)", this->_http_version.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 48,
"in_function : std::string http_response::http_version(std::string _http_version) : "
"_http_version(%s)", _http_version.c_str());
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 49,
"out_function : std::string http_response::http_version(std::string _http_version) : "
"return(%s)", ret.c_str());
}
*
* @return status code
*/
-std::string http_response::status_code()
+std::string http_response::status_code() const
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 50,
"in_function : std::string http_response::status_code(void)");
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 51,
"out_function : std::string http_response::status_code(void) : "
"return(%s)", this->_status_code.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 52,
"in_function : std::string http_response::status_code(std::string _status_code) : "
"_status_code(%s)", _status_code.c_str());
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 53,
"out_function : std::string http_response::status_code(std::string _status_code) : "
"return(%s)", ret.c_str());
}
*
* @return reason phrase
*/
-std::string http_response::reason_phrase()
+std::string http_response::reason_phrase() const
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 54,
"in_function : std::string http_response::reason_phrase(void)");
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 55,
"out_function : std::string http_response::reason_phrase(void) : "
"return(%s)", this->_reason_phrase.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 56,
"in_function : std::string http_response::reason_phrase(std::string _reason_phrase) : "
"_reason_phrase(%s)", _reason_phrase.c_str());
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 57,
"out_function : std::string http_response::reason_phrase(std::string _reason_phrase) : "
"return(%s)", ret.c_str());
}
*
* @return status line
*/
-std::string http_response::status_line()
+std::string http_response::status_line() const
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 58,
"in_function : std::string http_response::status_line(void)");
}
/*------ DEBUG LOG END ------*/
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 59,
"out_function : std::string http_response::status_line(void) : "
"return(%s)", ret.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 60,
"in_function : std::string http_response::as_string(void)");
}
/*------ DEBUG LOG END ------*/
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 61,
"out_function : std::string http_response::as_string(void) : "
"return(%s)", this->raw_message.c_str());
}
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 62,
"in_function : void http_response::parse(std::string response) : "
"response(%s)", response.c_str());
}
std::string::iterator end = response.end();
std::string::iterator start = ptr;
std::pair<std::string, std::string> field_pair;
- while (ptr != end) {
- switch(pos) {
- /*
- * STATUS-LINE :
- * HTTP-VERSION SP STATUS-CODE SP REASON-PHRASE CRLF
- */
- /*
- * HTTP-VERSION : "HTTP" "/" 1*DIGIT "." 1*DIGIT
- */
- case RESPONSE_TOP:
- // HTTP-VERSION start
- if (*ptr == 'H') {
- pos = RESPONSE_HTTP_VERSION_H;
- start = ptr;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ try {
+ while (ptr != end) {
+ switch(pos) {
+ /*
+ * STATUS-LINE :
+ * HTTP-VERSION SP STATUS-CODE SP REASON-PHRASE CRLF
+ */
+ /*
+ * HTTP-VERSION : "HTTP" "/" 1*DIGIT "." 1*DIGIT
+ */
+ case RESPONSE_TOP:
+ // HTTP-VERSION start
+ if (*ptr == 'H') {
+ pos = RESPONSE_HTTP_VERSION_H;
+ start = ptr;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 24,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_H:
- // HTTP-VERSION next
- if (*ptr == 'T') {
- pos = RESPONSE_HTTP_VERSION_T1;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_H:
+ // HTTP-VERSION next
+ if (*ptr == 'T') {
+ pos = RESPONSE_HTTP_VERSION_T1;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 25,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_T1:
- // HTTP-VERSION next
- if (*ptr == 'T') {
- pos = RESPONSE_HTTP_VERSION_T2;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_T1:
+ // HTTP-VERSION next
+ if (*ptr == 'T') {
+ pos = RESPONSE_HTTP_VERSION_T2;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 26,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_T2:
- // HTTP-VERSION next
- if (*ptr == 'P') {
- pos = RESPONSE_HTTP_VERSION_P;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_T2:
+ // HTTP-VERSION next
+ if (*ptr == 'P') {
+ pos = RESPONSE_HTTP_VERSION_P;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 27,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_P:
- // HTTP-VERSION next
- if (*ptr == '/') {
- pos = RESPONSE_HTTP_VERSION_SLASH;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_P:
+ // HTTP-VERSION next
+ if (*ptr == '/') {
+ pos = RESPONSE_HTTP_VERSION_SLASH;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 28,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_SLASH:
- // HTTP-VERSION Mejor number
- if (isdigit(*ptr)) {
- pos = RESPONSE_HTTP_VERSION_MAJOR;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_SLASH:
+ // HTTP-VERSION Mejor number
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_HTTP_VERSION_MAJOR;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 29,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_MAJOR:
- // HTTP-VERSION next dot
- if (*ptr == '.') {
- pos = RESPONSE_HTTP_VERSION_DOT;
- } else if (!isdigit(*ptr)) {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_MAJOR:
+ // HTTP-VERSION next dot
+ if (*ptr == '.') {
+ pos = RESPONSE_HTTP_VERSION_DOT;
+ } else if (!isdigit(*ptr)) {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 30,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_DOT:
- // HTTP-VERSION Minor number
- if (isdigit(*ptr)) {
- pos = RESPONSE_HTTP_VERSION_MINOR;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_DOT:
+ // HTTP-VERSION Minor number
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_HTTP_VERSION_MINOR;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 31,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_HTTP_VERSION_MINOR:
- // HTTP-VERSION end with SP
- if (*ptr == ' ') {
- pos = RESPONSE_HTTP_VERSION_SP;
- this->_http_version.assign(start, ptr);
- } else if (!isdigit(*ptr)) {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid HTTP-Version");
+ break;
+
+ case RESPONSE_HTTP_VERSION_MINOR:
+ // HTTP-VERSION end with SP
+ if (*ptr == ' ') {
+ pos = RESPONSE_HTTP_VERSION_SP;
+ this->_http_version.assign(start, ptr);
+ } else if (!isdigit(*ptr)) {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 32,
+ "Parse error: Invalid http-version.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- /*
- * Status-Code : 3DIGIT
- */
- case RESPONSE_HTTP_VERSION_SP:
- // STATUS-CODE start
- if (isdigit(*ptr)) {
- pos = RESPONSE_STATUS_CODE1;
- start = ptr;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Status-Code");
+ break;
+
+ /*
+ * Status-Code : 3DIGIT
+ */
+ case RESPONSE_HTTP_VERSION_SP:
+ // STATUS-CODE start
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_STATUS_CODE1;
+ start = ptr;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 33,
+ "Parse error: Invalid status-code.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_STATUS_CODE1:
- // STATUS-CODE next
- if (isdigit(*ptr)) {
- pos = RESPONSE_STATUS_CODE2;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Status-Code");
+ break;
+
+ case RESPONSE_STATUS_CODE1:
+ // STATUS-CODE next
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_STATUS_CODE2;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 34,
+ "Parse error: Invalid status-code.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_STATUS_CODE2:
- // STATUS-CODE next
- if (isdigit(*ptr)) {
- pos = RESPONSE_STATUS_CODE3;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Status-Code");
+ break;
+
+ case RESPONSE_STATUS_CODE2:
+ // STATUS-CODE next
+ if (isdigit(*ptr)) {
+ pos = RESPONSE_STATUS_CODE3;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 35,
+ "Parse error: Invalid status-code.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_STATUS_CODE3:
- // Status-Code end with SP
- if (*ptr == ' ') {
- pos = RESPONSE_STATUS_CODE_SP;
- this->_status_code.assign(start, ptr);
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Status-Code");
+ break;
+
+ case RESPONSE_STATUS_CODE3:
+ // Status-Code end with SP
+ if (*ptr == ' ') {
+ pos = RESPONSE_STATUS_CODE_SP;
+ this->_status_code.assign(start, ptr);
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 36,
+ "Parse error: Invalid status-code.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- /*
- * Reason-Phrase : *<TEXT, excluding CR, LF>
- */
- case RESPONSE_STATUS_CODE_SP:
- // Reason-Phrase is OCTET
- if (*ptr == '\r') { // omit reason-phrase
- pos = RESPONSE_CR;
- this->_reason_phrase.clear();
- } else if (*ptr != '\n') {
- pos = RESPONSE_REASON_PHRASE;
- start = ptr;
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Reason-Phrase");
+ break;
+
+ /*
+ * Reason-Phrase : *<TEXT, excluding CR, LF>
+ */
+ case RESPONSE_STATUS_CODE_SP:
+ // Reason-Phrase is OCTET
+ if (*ptr == '\r') { // omit reason-phrase
+ pos = RESPONSE_CR;
+ this->_reason_phrase.clear();
+ } else if (*ptr != '\n') {
+ pos = RESPONSE_REASON_PHRASE;
+ start = ptr;
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 37,
+ "Parse error: Invalid reason-phrase.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_REASON_PHRASE:
- // Reason-Phrase end with CR
- if (*ptr == '\r') {
- pos = RESPONSE_CR;
- this->_reason_phrase.assign(start, ptr);
- } else if (*ptr == '\n') {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : Invalid Reason-Phrase");
+ break;
+
+ case RESPONSE_REASON_PHRASE:
+ // Reason-Phrase end with CR
+ if (*ptr == '\r') {
+ pos = RESPONSE_CR;
+ this->_reason_phrase.assign(start, ptr);
+ } else if (*ptr == '\n') {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 38,
+ "Parse error: Invalid reason-phrase.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
- }
- break;
-
- case RESPONSE_CR:
- // LF only
- if (*ptr == '\n') {
- pos = RESPONSE_LF;
- http_message::parse(std::string(ptr + 1, end));
- } else {
- /*-------- DEBUG LOG --------*/
- if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
- "out_function : void http_response::parse(std::string response) : not CRLF");
+ break;
+
+ case RESPONSE_CR:
+ // LF only
+ if (*ptr == '\n') {
+ pos = RESPONSE_LF;
+ http_message::parse(std::string(ptr + 1, end));
+ } else {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 39,
+ "Parse error: No LF.(%c)", *ptr);
+ throw -1;
}
- /*------ DEBUG LOG END ------*/
- throw -1;
+ break;
}
- break;
+ if (pos == RESPONSE_LF)
+ break;
+ ptr++;
}
- if (pos == RESPONSE_LF)
- break;
- ptr++;
+ }
+ catch (...) {
+ LOGGER_PUT_LOG_ERROR(LOG_CAT_PACKET_EDIT_HTTP, 40,
+ "Exception occured by parsing HTTP response.");
}
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 63,
"out_function : void http_response::parse(std::string response)");
}
/*------ DEBUG LOG END ------*/
{
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 64,
"in_function : void http_response::rebuild()");
}
/*------ DEBUG LOG END ------*/
/*-------- DEBUG LOG --------*/
if (LOG_LV_DEBUG == logger_get_log_level(LOG_CAT_PACKET_EDIT_HTTP)) {
- LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 3, // XXX log
+ LOGGER_PUT_LOG_DEBUG(LOG_CAT_PACKET_EDIT_HTTP, 65,
"out_function : void http_response::rebuild()");
}
/*------ DEBUG LOG END ------*/