Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

How to determine the boundaries of HTTP header? #493

Closed
wonter opened this issue Sep 24, 2019 · 1 comment
Closed

How to determine the boundaries of HTTP header? #493

wonter opened this issue Sep 24, 2019 · 1 comment

Comments

@wonter
Copy link

wonter commented Sep 24, 2019

Hi

I am writing an http proxy and parsing HTTP messages using http-parser

In most cases, proxy will add some additional headers such as ‎X-Forwarded-Host, Proxy-Authorization and so on

So i'd like to split HTTP message to 3 parts which is:

  1. original header
  2. additional headers
  3. body

But http-parser doesn't provide some API to help me determine the boundaries of HTTP header

Is there any way to do it?

@bnoordhuis
Copy link
Member

http-parser is basically a state machine so if you keep track of when your callbacks are invoked, you can keep track of the state.

on_header_field, on_header_value and on_headers_complete in particular are the callbacks you'd care about.

@wonter wonter closed this as completed Sep 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants