source: cheroxy/trunk/src/CRXHttpResponse.cpp@ 6

Last change on this file since 6 was 6, checked in by cheese, 12 years ago

#1 개발버전 게시

File size: 1.4 KB
Line 
1/**
2 * CRXHttpResponse.cpp
3 */
4#ifdef _WIN32
5# pragma warning (disable:4996)
6#endif
7
8#include "CRXHttpResponse.h"
9
10#include <iostream>
11#include <stdio.h>
12#include <stdlib.h>
13
14CRXHttpResponse::CRXHttpResponse (void)
15 : mStatusCode (0)
16{
17}
18
19void
20CRXHttpResponse::SetResponse (const char * aHttpResponse)
21{
22 SetMessage (aHttpResponse);
23}
24
25std::string
26CRXHttpResponse::GetResponse (void) const
27{
28 return GetMessage ();
29}
30
31CRXHttpResponse &
32CRXHttpResponse::operator = (const char * aHttpMessage)
33{
34 SetMessage (aHttpMessage);
35 return *this;
36}
37
38void
39CRXHttpResponse::Parse (void)
40{
41 std::string aHttpStatus = "";
42
43 char aStatusCode[64] = {0x00, };
44 char aStatusString[64] = {0x00, };
45 char aHttpVersion[64] = {0x00, };
46
47 /*----------------------------------------------------------------*/
48 aHttpStatus = GetResponse ().substr (0, mHttpMessage.find ('\r'));
49
50 /*----------------------------------------------------------------
51 * 1. separate first line to <METHOD>, <URL> and <VERSION>
52 *----------------------------------------------------------------*/
53 sscanf (aHttpStatus.c_str (), "%[^ ] %[^ ] %[^ ]\r\n", aHttpVersion, aStatusCode, aStatusString);
54 mHttpVersion.assign (aHttpVersion);
55 mStatusString.assign (aStatusString);
56 mStatusCode = atoi (aStatusCode);
57
58 /*----------------------------------------------------------------*/
59}
60
61int
62CRXHttpResponse::GetStatusCode (void) const
63{
64 return mStatusCode;
65}
Note: See TracBrowser for help on using the repository browser.