我正在使用一个 Web 应用程序,它在响应登录请求时发送一些非标准的 HTTP 标头。有问题的标题是:
SSO_STATUS: LoginFailed
我试图用 LWP::Response 提取它,$response->header('SSO_STATUS')
但它不起作用。Set-Cookie
它确实适用于标准标题,例如Expires
等。
有没有办法使用原始标题?
如果您看到HTTP::Headers的文档,它会指出
标头字段名称拼写通常是规范化的,包括“_”到“-”的翻译。有些应用程序不适合这样做。使用 ':' 为字段名称添加前缀允许您强制使用特定的拼写。例如,如果您真的希望标题字段名称显示为 foo_bar 而不是“Foo-Bar”,则可以这样设置:
$h->header(":foo_bar" => 1);
这些字段名称与完整的“:”
$h->header_field_names
和$h->scan
回调一起返回,但冒号不显示在$h->as_string
.
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');