Tcl Source Code

View Ticket
Login
Ticket UUID: 2927221
Title: provide helper function to get http headers
Type: RFE Created on: 2010-01-06 22:44:10
Submitter: dvrsn Assigned to: patthoyts
Subsystem: 29. http Package Severity: Minor
Priority: 5 Medium Last modified: 2022-09-10 11:57:24
Status: Closed Closed by: kjnash
Resolution: Fixed Closed on: 2022-09-10 11:57:24
Version: None
Description:
The http package puts the response headers into the meta element of the state array exactly as they are received from the server.  If a program needs to get a specific well-known header (i.e., Location) they must search the meta array in a case-insensitive manner rather than just accessing the keys.  

The requested feature is to provide a case-insensitive lookup into the meta array, either through a new helper function (::http::header) or by having http::meta take an optional key argument to return only the requested key instead of the entire array.  (::http::meta token ?key?)
User Comments:
ferrieux added on 2010-01-07 16:29:47:
A new helper function ::http::header would indeed be the simplest, returning basically the same key-value list (isomorphous to a dict BTW) as ::meta but with [string tolower] applied to the keys.

kjnash added on 2022-09-10 11:57:24:
Fixed in commit [31732edc8a], branch http-bugfixes-2022H2.

N.B. the list of header names and values is not a dict because the same header name can be sent more than once.