federicotdn / verb

Organize and send HTTP requests from Emacs
https://melpa.org/#/verb
GNU General Public License v3.0
545 stars 20 forks source link

Allow request headers with underscores #36

Closed mcraveiro closed 3 years ago

mcraveiro commented 3 years ago

Hi verb-mode developers,

thank you for an extremely useful Emacs mode, which I use daily. I have one very small request: to allow underscores in HTTP headers. I bumped into an issue at work where they used underscores, and it is apparently legal according to the protocol [1]. In order to get verb-mode to process my requests, I changed the regex (in [2]) as follows:

 (if (string-match "^\\s-*\\([[:alnum:]-_]+\\)\\s-*:\\(.*\\)$"
                              line)

i.e., added the underscore after alnum, not sure if this is the best of fixes. If you are ok with this (or have a better suggestion) let me know and I'll submit a PR.

Many thanks for your time.

[1] https://stackoverflow.com/questions/22856136/why-do-http-servers-forbid-underscores-in-http-header-names [2] https://github.com/federicotdn/verb/blob/master/verb.el#L2318

federicotdn commented 3 years ago

Thanks for bringing this up! Fixed in https://github.com/federicotdn/verb/commit/119514532f12301d7593a0dbe4eee778cc8dcf98

mcraveiro commented 3 years ago

Thanks very much for the fast turn around! Now, I don't want to be that ungrateful customer :-) but may I ask, don't you also have to also update the regex for font-locking headers? The strange thing is I can already see an underscore in there, just not as part of this patch, so it's probably all good. But I'll mention it just in case :-)

(defconst verb--http-header-parse-regexp
  "^\\s-*\\([[:alnum:]_-]+\\)\\s-*:\\(.*\\)$"
  "Regexp for parsing HTTP headers.")

Cheers

federicotdn commented 3 years ago

That's true! Thanks for bringing that up, pushed another change to master.