Changeset 35 in cheroxy for trunk/src/CRXProxy.cpp
- Timestamp:
- 11/20/12 19:06:30 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/CRXProxy.cpp
r34 r35 99 99 { 100 100 aResult = ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST; 101 CRX_ERROR (aResult, "Failed to receive from client");101 CRX_ERROR_SET (aResult, "Failed to receive from client."); 102 102 } 103 103 … … 106 106 { 107 107 aResult = ERROR_PROXY_FAILED_TO_SEND_REQUEST; 108 CRX_ERROR (aResult, "Failed to send to server");108 CRX_ERROR_SET (aResult, "Failed to send to server."); 109 109 return aResult; 110 110 } … … 114 114 { 115 115 aResult = ERROR_PROXY_FAILED_TO_RECEIVE_RESPONSE; 116 CRX_ERROR (aResult, "Failed to receive from server");116 CRX_ERROR_SET (aResult, "Failed to receive from server."); 117 117 } 118 118 … … 121 121 { 122 122 aResult = ERROR_PROXY_FAILED_TO_SEND_RESPONSE; 123 CRX_ERROR (aResult, "Failed to send to client");123 CRX_ERROR_SET (aResult, "Failed to send to client."); 124 124 return aResult; 125 125 } … … 177 177 178 178 char * 179 CRXProxy::GetHttpResponse (char* aBuffer,180 179 CRXProxy::GetHttpResponseHeader (char * aBuffer, 180 const int aBufferSize) const 181 181 { 182 182 void * aPtr = static_cast<void *> (aBuffer); … … 185 185 int aRemainLength = aBufferSize; 186 186 const int aHeaderLength = mHttpResponse.GetHeader ().length (); 187 const int aContentLength = mHttpResponse.GetContentLength ();188 187 189 188 /*----------------------------------------------------------------*/ … … 194 193 if (aCopyLength > 0) 195 194 memcpy (aPtr, mHttpResponse.GetHeader ().c_str (), aCopyLength); 196 197 aRemainLength -= aCopyLength; 195 /*----------------------------------------------------------------*/ 196 197 return aBuffer; 198 } 199 200 int 201 CRXProxy::GetHttpResponseHeaderLength (void) const 202 { 203 /*----------------------------------------------------------------*/ 204 /*----------------------------------------------------------------*/ 205 206 return mHttpResponse.GetHeader ().length (); 207 } 208 209 char * 210 CRXProxy::GetHttpResponseBody (char * aBuffer, 211 const int aBufferSize) const 212 { 213 void * aPtr = static_cast<void *> (aBuffer); 214 215 int aCopyLength = 0; 216 int aRemainLength = aBufferSize; 217 const int aContentLength = mHttpResponse.GetContentLength (); 218 219 /*----------------------------------------------------------------*/ 220 if (aPtr == NULL) 221 return NULL; 198 222 199 223 aCopyLength = aRemainLength < aContentLength ? aRemainLength : aContentLength; … … 206 230 207 231 int 208 CRXProxy::GetHttpResponseLength (void) const 209 { 210 /*----------------------------------------------------------------*/ 211 /*----------------------------------------------------------------*/ 212 213 return mHttpResponse.GetHeader ().length () 214 + mHttpResponse.GetContentLength (); 232 CRXProxy::GetHttpResponseBodyLength (void) const 233 { 234 /*----------------------------------------------------------------*/ 235 /*----------------------------------------------------------------*/ 236 237 return mHttpResponse.GetContentLength (); 215 238 } 216 239 … … 228 251 { 229 252 aResult = ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST; 230 CRX_ ERROR_ADD (mClient.GetErrorMessage ().c_str ());231 CRX_ERROR (aResult, "Failed to receive from client");253 CRX_ADD_SUBCLASS_ERROR (mClient); 254 CRX_ERROR_SET (aResult, "Failed to receive from client."); 232 255 return aResult; 233 256 } … … 254 277 { 255 278 aResult = ERROR_PROXY_FAILED_TO_CONNECT_TO_SERVER; 256 CRX_ ERROR_ADD (mServer.GetErrorMessage ().c_str ());257 CRX_ERROR (aResult, "Failed to connect to server <%s>", mHttpRequest.GetURL ().c_str ());279 CRX_ADD_SUBCLASS_ERROR (mServer); 280 CRX_ERROR_SET (aResult, "Failed to connect to server <%s>.", mHttpRequest.GetURL ().c_str ()); 258 281 return aResult; 259 282 } … … 263 286 if (aResult != aSize) 264 287 { 265 CRX_ ERROR_ADD (mServer.GetErrorMessage ().c_str ());266 CRX_ERROR (aResult, "Failed to send to server <%s>", mHttpRequest.GetURL ().c_str ());288 CRX_ADD_SUBCLASS_ERROR (mServer); 289 CRX_ERROR_SET (aResult, "Failed to send to server <%s>.", mHttpRequest.GetURL ().c_str ()); 267 290 } 268 291 /*----------------------------------------------------------------*/ … … 290 313 { 291 314 aResult = ERROR_PROXY_FAILED_TO_RECEIVE_REQUEST; 292 CRX_ ERROR_ADD (mServer.GetErrorMessage ().c_str ());293 CRX_ERROR (aResult, "Failed to receive from server");315 CRX_ADD_SUBCLASS_ERROR (mServer); 316 CRX_ERROR_SET (aResult, "Failed to receive from server."); 294 317 return aResult; 295 318 } … … 303 326 { 304 327 aResult = ERROR_PROXY_FAILED_TO_SET_RESPONSE; 305 CRX_ERROR (aResult, "Failed to set response");328 CRX_ERROR_SET (aResult, "Failed to set response."); 306 329 return aResult; 330 } 331 332 if (!CheckRequestFilter (CRX_FILTER_REQUEST_FILE_EXTENSION) && 333 mHttpResponse.GetContentLength () > 0) 334 { 335 CRX_DEBUG_TRACE_BIN (mHttpResponse.GetContentBody (), 336 mHttpResponse.GetContentLength (), 337 ""); 307 338 } 308 339 } … … 323 354 if (aResult != aSize) 324 355 { 325 CRX_ ERROR_ADD (mClient.GetErrorMessage ().c_str ());326 CRX_ERROR (aResult, "Failed to send to client");356 CRX_ADD_SUBCLASS_ERROR (mClient); 357 CRX_ERROR_SET (aResult, "Failed to send to client."); 327 358 return aResult; 328 359 } … … 332 363 if (aResult != aSize) 333 364 { 334 CRX_ ERROR_ADD (mClient.GetErrorMessage ().c_str ());335 CRX_ERROR (aResult, "Failed to send to client");365 CRX_ADD_SUBCLASS_ERROR (mClient); 366 CRX_ERROR_SET (aResult, "Failed to send to client."); 336 367 } 337 368 /*----------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.