Skip Menu |

This queue is for tickets about the REST-Client CPAN distribution.

Report information
The Basics
Id: 92590
Status: resolved
Priority: 0/
Queue: REST-Client

People
Owner: Nobody in particular
Requestors: robert.israel [...] teamaol.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: REST::Client rewriting headers
Date: Thu, 30 Jan 2014 16:24:58 -0500
To: <bug-REST-Client [...] rt.cpan.org>
From: Robert Israel <robert.israel [...] teamaol.com>
Hello! When using REST::Client, when specifying header fields as "user_name" and "license_key", they get rewritten as "User-Name" and "License-Key", with poor results in servers that care about capitalization and underscores not being dashes. For example, this code: my $headers = {Accept => 'application/json', 'Content-type' => 'application/json', 'user_name' => $username, 'license_key' => $password }; results in the following going over the wire (examined via tcpdump) to the remote server: Accept: application/json Host: {redacted} User-Agent: REST::Client/171 Content-Length: 0 Content-Type: application/json License-Key: {redacted} User-Name: {redacted} As you can see, license_key has become License-Key, and user_name has become User-Name. This prevents me from authenticating. Using curl, which does not change the case/underscores, things work properly. Thank you! -Rob
That's not REST::Client, that's the standard HTTP libraries protecting you from invalid headers. See for details: http://search.cpan.org/~gaas/HTTP-Message-6.06/lib/HTTP/Headers.pm#NON-CANONICALIZED_FIELD_NAMES Your best option is to make the server use standards-compliant headers with case insensitivity and dashes. If that's not an option, it looks like you can prefix them with a colon. Or, feel free to reset the UA that REST::Client is using.
Subject: Re: [rt.cpan.org #92590] REST::Client rewriting headers
Date: Thu, 30 Jan 2014 17:08:32 -0500
To: <bug-REST-Client [...] rt.cpan.org>
From: Robert Israel <robert.israel [...] teamaol.com>
Miles, Well, I can't get the third party vendor to change their stuff, but the adding a colon thing totally worked. Thank you very much for the help! -Rob Miles Crawford via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=92590 > > > > That's not REST::Client, that's the standard HTTP libraries protecting you from invalid headers. > > See for details: http://search.cpan.org/~gaas/HTTP-Message-6.06/lib/HTTP/Headers.pm#NON-CANONICALIZED_FIELD_NAMES > > Your best option is to make the server use standards-compliant headers with case insensitivity and dashes. > > If that's not an option, it looks like you can prefix them with a colon. Or, feel free to reset the UA that REST::Client is using. >