views:

65

answers:

2

I'm working with a web application that sends some non-standard HTTP headers in its response to a login request. The header in question is:

SSO_STATUS: LoginFailed 

I tried to extract it with LWP::Response as $response->header('SSO_STATUS') but it does not work. It does work for standard headers such as Set-Cookie, Expires etc.

Is there a way to work with the raw headers?

+3  A: 

See this thread on Perlmonks.

You need to access the value of the header field as $response->header('SSO-STATUS').

The syntax for setting fields with underscores in names:
$response->header(':SSO_STATUS' => 'foo');

eugene y
$response->header('SSO-STATUS') does not work.
Yahya
$response->headers_as_string get's all the headers, and I can do a regexp match on that, but it would be nice to have a cleaner way.
Yahya
+6  A: 

if you see the documentation of HTTP::Headers, it states that

The header field name spelling is normally canonicalized including the '_' to '-' translation. There are some application where this is not appropriate. Prefixing field names with ':' allow you to force a specific spelling. For example if you really want a header field name to show up as foo_bar instead of "Foo-Bar", you might set it like this:

  $h->header(":foo_bar" => 1);

These field names are returned with the ':' intact for $h->header_field_names and the $h->scan callback, but the colons do not show in $h->as_string.

Nikhil Jain
I am not trying to set headers. I just want to read this non-standard header.
Yahya