Changeset 45 in cheroxy for trunk/src/CRXProxy.cpp
- Timestamp:
- 11/22/12 18:38:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/CRXProxy.cpp
r44 r45 9 9 CRXFilter CRXProxy::mFilter; 10 10 11 CRXProxy::CRXProxy (void) 12 : mClient (0), 13 mServer (0), 14 mServerTimeout (0) 15 { 16 /*----------------------------------------------------------------*/ 11 CRXProxy::CRXProxy (const int aSocket) 12 : mServerTimeout (0) 13 { 14 /*----------------------------------------------------------------*/ 15 if (aSocket < 0) 16 return ; 17 18 mClient = aSocket; 17 19 /*----------------------------------------------------------------*/ 18 20 } … … 22 24 /*----------------------------------------------------------------*/ 23 25 Close (); 24 /*----------------------------------------------------------------*/25 }26 27 void28 CRXProxy::SetClientSocket (const int aSocket)29 {30 /*----------------------------------------------------------------*/31 if (aSocket <= 0)32 return ;33 34 mClient = aSocket;35 26 /*----------------------------------------------------------------*/ 36 27 } … … 51 42 mClient.Close (); 52 43 /*----------------------------------------------------------------*/ 53 }54 55 void56 CRXProxy::SetRequestFilter (const E_CRX_FILTER_REQUEST aType,57 const bool aIsMatched,58 const std::string aValue)59 {60 /*----------------------------------------------------------------*/61 mFilter.SetRequestFilter (aType, aIsMatched, aValue);62 /*----------------------------------------------------------------*/63 }64 65 void66 CRXProxy::RemoveRequestFilter (const E_CRX_FILTER_REQUEST aType)67 {68 /*----------------------------------------------------------------*/69 mFilter.RemoveRequestFilter (aType);70 /*----------------------------------------------------------------*/71 }72 73 bool74 CRXProxy::CheckRequestFilter (const E_CRX_FILTER_REQUEST aType)75 {76 /*----------------------------------------------------------------*/77 /*----------------------------------------------------------------*/78 79 return mFilter.CheckRequestFilter (aType, this->mHttpRequest);80 44 } 81 45 … … 120 84 } 121 85 122 void123 CRXProxy::SetHttpRequest (const char * aHttpRequest)124 {125 /*----------------------------------------------------------------*/126 mHttpRequest.SetHeader (aHttpRequest);127 /*----------------------------------------------------------------*/128 }129 130 char *131 CRXProxy::GetHttpRequest (char * aBuffer,132 const int aBufferSize) const133 {134 void * aPtr = static_cast<void *> (aBuffer);135 136 int aCopyLength = 0;137 int aRemainLength = aBufferSize;138 const int aHeaderLength = mHttpRequest.GetHeader ().length ();139 140 /*----------------------------------------------------------------*/141 if (aPtr == NULL)142 return NULL;143 144 aCopyLength = aRemainLength < aHeaderLength ? aBufferSize : aHeaderLength;145 if (aCopyLength > 0)146 memcpy (aPtr, mHttpRequest.GetHeader ().c_str (), aCopyLength);147 /*----------------------------------------------------------------*/148 149 return aBuffer;150 }151 152 int153 CRXProxy::GetHttpRequestLength (void) const154 {155 /*----------------------------------------------------------------*/156 /*----------------------------------------------------------------*/157 158 return mHttpRequest.GetHeader().length ();159 }160 161 void162 CRXProxy::SetHttpResponse (const char * aHttpResponse)163 {164 /*----------------------------------------------------------------*/165 mHttpResponse.SetHeader (aHttpResponse);166 /*----------------------------------------------------------------*/167 }168 169 char *170 CRXProxy::GetHttpResponseHeader (char * aBuffer,171 const int aBufferSize) const172 {173 void * aPtr = static_cast<void *> (aBuffer);174 175 int aCopyLength = 0;176 int aRemainLength = aBufferSize;177 const int aHeaderLength = mHttpResponse.GetHeader ().length ();178 179 /*----------------------------------------------------------------*/180 if (aPtr == NULL)181 return NULL;182 183 aCopyLength = aRemainLength < aHeaderLength ? aBufferSize : aHeaderLength;184 if (aCopyLength > 0)185 memcpy (aPtr, mHttpResponse.GetHeader ().c_str (), aCopyLength);186 /*----------------------------------------------------------------*/187 188 return aBuffer;189 }190 191 int192 CRXProxy::GetHttpResponseHeaderLength (void) const193 {194 /*----------------------------------------------------------------*/195 /*----------------------------------------------------------------*/196 197 return mHttpResponse.GetHeader ().length ();198 }199 200 char *201 CRXProxy::GetHttpResponseBody (char * aBuffer,202 const int aBufferSize) const203 {204 void * aPtr = static_cast<void *> (aBuffer);205 206 int aCopyLength = 0;207 int aRemainLength = aBufferSize;208 const int aContentLength = mHttpResponse.GetContentLength ();209 210 /*----------------------------------------------------------------*/211 if (aPtr == NULL)212 return NULL;213 214 aCopyLength = aRemainLength < aContentLength ? aRemainLength : aContentLength;215 if (aCopyLength > 0)216 memcpy (aPtr, mHttpResponse.GetContentBody (), aCopyLength);217 /*----------------------------------------------------------------*/218 219 return aBuffer;220 }221 222 int223 CRXProxy::GetHttpResponseBodyLength (void) const224 {225 /*----------------------------------------------------------------*/226 /*----------------------------------------------------------------*/227 228 return mHttpResponse.GetContentLength ();229 }230 231 86 int 232 87 CRXProxy::ReceiveRequest (void) … … 315 170 316 171 aResult = mHttpResponse.SetResponseAll (aBuffer, aResult); 317 if (aResult )172 if (aResult < 0) 318 173 { 319 174 aResult = ERROR_PROXY_FAILED_TO_SET_RESPONSE; … … 354 209 return aResult < 0 ? aResult : 0; 355 210 } 211 212 CRXFilter & 213 CRXProxy::GetFilter (void) const 214 { 215 /*----------------------------------------------------------------*/ 216 /*----------------------------------------------------------------*/ 217 218 return mFilter; 219 } 220 221 CRXHttpRequest & 222 CRXProxy::GetHttpRequest (void) 223 { 224 /*----------------------------------------------------------------*/ 225 /*----------------------------------------------------------------*/ 226 227 return mHttpRequest; 228 } 229 230 CRXHttpResponse & 231 CRXProxy::GetHttpResponse (void) 232 { 233 /*----------------------------------------------------------------*/ 234 /*----------------------------------------------------------------*/ 235 236 return mHttpResponse; 237 }
Note:
See TracChangeset
for help on using the changeset viewer.