Merge pull request #10483 from redism/ios-network-header-fix

apply custom request header for every request type (ios)
This commit is contained in:
minggo 2015-02-26 16:40:12 +08:00
commit e69e648d7c
1 changed files with 17 additions and 16 deletions

View File

@ -167,13 +167,6 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream
//set request type //set request type
[nsrequest setHTTPMethod:requestType]; [nsrequest setHTTPMethod:requestType];
//if request type is post or put,set header and data
if([requestType isEqual: @"POST"] || [requestType isEqual: @"PUT"])
{
if ([requestType isEqual: @"PUT"])
{
[nsrequest setValue: @"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-Type"];
}
/* get custom header data (if set) */ /* get custom header data (if set) */
std::vector<std::string> headers=request->getHeaders(); std::vector<std::string> headers=request->getHeaders();
if(!headers.empty()) if(!headers.empty())
@ -191,6 +184,14 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream
} }
} }
//if request type is post or put,set header and data
if([requestType isEqual: @"POST"] || [requestType isEqual: @"PUT"])
{
if ([requestType isEqual: @"PUT"])
{
[nsrequest setValue: @"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-Type"];
}
char* requestDataBuffer = request->getRequestData(); char* requestDataBuffer = request->getRequestData();
if (nullptr != requestDataBuffer && 0 != request->getRequestDataSize()) if (nullptr != requestDataBuffer && 0 != request->getRequestDataSize())
{ {