HttpRequest type:GET Headers not supported iOS

Hi I’ve found that supplying headers with a HTTP Request of type GET doesn’t work/isn’t allowed and the server doesn’t receive any of the header information.

I’ve also noticed that in the CppTests the Network test for the Get method doesn’t supply any headers either, almost like it’s intentional.

Is this a bug or is it intentional? I don’t understand the reason for not being able to supply headers with the GET method.

Note: this is specifically in the iOS class HttpClient-ios.mm, maybe iOS doesn’t support GET requests with headers?

For anyone that’s interested I got it working by adding extra code after this IF block in HttpClient-ios.mm.

//if request type is post or put,set header and data if([requestType isEqual: @"POST"] || [requestType isEqual: @"PUT"]) { .... }

And this is the new code…

// If request type is GET supply the header information from the request, no data is required

if ([requestType isEqual: @“GET”])
{
std::vectorstd::string headers=request->getHeaders();
if(!headers.empty())
{
/* append custom headers one by one */
for (std::vectorstd::string::iterator it = headers.begin(); it != headers.end(); ++it)
{
unsigned long i = it->find(‘:’, 0);
unsigned long length = it->size();
std::string field = it->substr(0, i);
std::string value = it->substr(i+1, length-i);
NSString *headerField = [NSString stringWithUTF8String:field.c_str()];
NSString *headerValue = [NSString stringWithUTF8String:value.c_str()];
[nsrequest setValue:headerValue forHTTPHeaderField:headerField];
}
}
}

p.s. apologies about the indentation it wouldn’t save the formatting when I pasted it.

did you test this change?

Have you seen our videos on HTTP Request https://www.youtube.com/playlist?list=PLRtjMdoYXLf7g6xBzWfJpbDZlPedjwggH