0

I'm working on a Google Chrome extension that does some processing based on HTTP response headers using the chrome.webRequest.onHeadersReceived event. I'm able to receive the headers, but the documentation seems to indicate that the headers are just represented as simple string name-value pairs.

The values for some HTTP headers, particularly Content-Type and Content-Disposition in my case, can store multiple pieces of information, including parameters with special mechanisms to escape characters. I want to be able to semantically interpret the header values rather than just see them as strings.

However, I don't want to have to write my own HTTP header value parsing code to meet the HTTP specifications and be able to cope with real-world values; I consider this an entire project of its own, and I want to focus on developing my extension.

How can I achieve this?

Sam
  • 40,644
  • 36
  • 176
  • 219
  • 1
    Writing your own parser is the only option, there's no built-in method. You could try to Google for existing libraries. – Rob W Apr 14 '13 at 08:26
  • You should elaborate on why you cannot use `Content-Type` values as strings. What is your end goal with these values? – Brandon Apr 14 '13 at 08:30

0 Answers0