Skip to content

Cookie extraction should use case-insensitive comparison for headers #855

@paurkedal

Description

@paurkedal

The HTTP headers are not always lower cased. For instance, when working with the mediawiki Docker container I'm getting a Set-Cookie field instead of set-cookie, which Cohttp.Cookie.Set_cookie_hdr.extract assumes, and this makes a difference:

utop # #require "cohttp";;
utop # Cohttp.Header.of_list ["set-cookie", "my_wiki_session=bq02atpavmnv00b2mn6j62sc5li43cu3; path=/; HttpOnly"] |> Cohttp.Cookie.Set_cookie_hdr.extract;;
- : (string * Cohttp.Cookie.Set_cookie_hdr.t) list =
[("my_wiki_session",
  {Cohttp.Cookie.Set_cookie_hdr.cookie =
    ("my_wiki_session", "bq02atpavmnv00b2mn6j62sc5li43cu3");
   expiration = `Session; domain = None; path = Some "/"; secure = false;
   http_only = true})]
utop # Cohttp.Header.of_list ["Set-Cookie", "my_wiki_session=bq02atpavmnv00b2mn6j62sc5li43cu3; path=/; HttpOnly"] |> Cohttp.Cookie.Set_cookie_hdr.extract;;
- : (string * Cohttp.Cookie.Set_cookie_hdr.t) list = []

I am thinking it could be passed through String.lowercase_ascii, but I'm not sure if the best place would be when parsed, on-demand in the iterators, or on the consumer side (in exctract).

I'm using Cohttp 5.0.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions