Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / apps / JAWS2 / HTTPU / parse_http_response.cpp
blob9950503f65934d6d9e20683f0f843aa98e1f7f92
1 #include "HTTPU/parse_http_response.h"
2 #include "ace/OS_NS_string.h"
3 #include "ace/OS_NS_stdlib.h"
5 Parse_HTTP_Response::Parse_HTTP_Response (const char *response)
6 : code_ (200),
7 code_str_ (0),
8 major_version_ (0),
9 minor_version_ (9),
10 version_ (0),
11 response_ (0),
12 error_ (0)
14 if (response != 0)
15 this->init (response);
18 Parse_HTTP_Response::~Parse_HTTP_Response ()
20 if (this->response_)
21 ACE_OS::free (this->response_);
22 this->response_ = 0;
23 this->code_str_ = 0;
24 this->version_ = 0;
27 void
28 Parse_HTTP_Response::init (const char *response)
30 this->response_ = ACE_OS::strdup (response);
31 if (this->response_ == 0)
33 this->error_ = NO_MEMORY;
34 return;
37 int n = ::sscanf (this->response_, "HTTP/%d.%d %d %*s",
38 &(this->major_version_),
39 &(this->minor_version_),
40 &(this->code_));
42 if (n == 3)
44 char *p = this->response_;
46 while (*p == ' ' || *p == '\t')
47 p++;
49 this->version_ = p++;
51 while (*p != ' ' && *p != '\t')
52 p++;
54 *p++ = '\0';
56 while (*p == ' ' || *p == '\t')
57 p++;
59 this->code_str_ = p;
61 while (*p && !ACE_OS::strchr (" \t\r\n", *p))
62 p++;
64 *p++ = '\0';
66 else
67 this->error_ = BAD_RESPONSE;
70 #if !defined (ACE_HAS_INLINED_OSCALLS)
71 # include "HTTPU/parse_http_response.inl"
72 #endif /* ACE_HAS_INLINED_OSCALLS */