Changeset 44 in cheroxy for trunk/src/CRXProxy.cpp
- Timestamp:
- 11/22/12 15:21:02 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/CRXProxy.cpp
r40 r44 25 25 } 26 26 27 CRXProxy *28 CRXProxy::GetNewInstance (void)29 {30 /*----------------------------------------------------------------*/31 /*----------------------------------------------------------------*/32 33 return new(std::nothrow) CRXProxy ();34 }35 36 void37 CRXProxy::ReleaseInstance (void)38 {39 /*----------------------------------------------------------------*/40 delete this;41 /*----------------------------------------------------------------*/42 }43 44 27 void 45 28 CRXProxy::SetClientSocket (const int aSocket) … … 141 124 { 142 125 /*----------------------------------------------------------------*/ 143 mHttpRequest = aHttpRequest;126 mHttpRequest.SetHeader (aHttpRequest); 144 127 /*----------------------------------------------------------------*/ 145 128 } … … 158 141 if (aPtr == NULL) 159 142 return NULL; 160 143 161 144 aCopyLength = aRemainLength < aHeaderLength ? aBufferSize : aHeaderLength; 162 145 if (aCopyLength > 0) … … 180 163 { 181 164 /*----------------------------------------------------------------*/ 182 mHttpResponse = aHttpResponse;165 mHttpResponse.SetHeader (aHttpResponse); 183 166 /*----------------------------------------------------------------*/ 184 167 } … … 249 232 CRXProxy::ReceiveRequest (void) 250 233 { 251 int aResult = 0; 252 253 const unsigned int aBufferSize = 1024 * 56; 254 char aBuffer[aBufferSize + 1] = {0x00, }; 255 256 /*----------------------------------------------------------------*/ 257 aResult = mClient.Receive (aBuffer, aBufferSize); 258 if (aResult < 0) 259 { 260 aResult = ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST; 261 CRX_ADD_SUBCLASS_ERROR (mClient); 262 CRX_ERROR_SET (aResult, "Failed to receive from client."); 263 return aResult; 264 } 265 266 /* parse http request */ 267 mHttpRequest = aBuffer; 234 int aResult = 0; 235 char aBuffer; 236 237 std::string aHttpHeader; 238 /*----------------------------------------------------------------*/ 239 for (;;) 240 { 241 aResult = mClient.Receive (&aBuffer, 1); 242 if (aResult < 0) 243 { 244 aResult = ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST; 245 CRX_ADD_SUBCLASS_ERROR (mClient); 246 CRX_ERROR_SET (aResult, "Failed to receive from client."); 247 return aResult; 248 } 249 aHttpHeader += aBuffer; 250 if (aHttpHeader.rfind (CRLF2) != std::string::npos) 251 break; 252 } 253 254 mHttpRequest.SetHeader (aHttpHeader.c_str ()); 268 255 /*----------------------------------------------------------------*/ 269 256 … … 292 279 return aResult; 293 280 } 294 295 if (getsockname (mServer, (struct sockaddr *) &aSockName, &aSockLen) == 0)296 CRX_DEBUG_TRACE ("Connected on port number (%d)\n", ntohs (aSockName.sin_port));297 281 } 298 282 … … 315 299 const unsigned int aBufferSize = 1024 * 64; 316 300 char aBuffer[aBufferSize + 1] = {0x00, }; 317 318 std::string aHttpResponse;319 301 320 302 /*----------------------------------------------------------------*/ … … 331 313 return aResult; 332 314 } 333 else if (aResult == 0) 334 { 335 break; 336 } 337 338 aResult = mHttpResponse.SetResponse (aBuffer, aResult); 315 316 aResult = mHttpResponse.SetResponseAll (aBuffer, aResult); 339 317 if (aResult) 340 318 { … … 343 321 return aResult; 344 322 } 345 346 if (!CheckRequestFilter (CRX_FILTER_REQUEST_FILE_EXTENSION) &&347 mHttpResponse.GetContentLength () > 0)348 {349 CRX_DEBUG_TRACE_BIN (mHttpResponse.GetContentBody (),350 mHttpResponse.GetContentLength (),351 "");352 }353 323 } 354 324 /*----------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.