-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
method might not refer to a location within buffer #124
Comments
Following up on this. I came up with three possible solutions:
I ended up going with the last approach. For each connection we were allocating two |
@jkarneges I'll fix this for the next release, my fault, it makes sense to return buffer pointers instead of static strings. |
Instead of static constants for GET/POST, fixes seanmonstar#124
Instead of static constants for GET/POST, fixes #124
Our app parses a request but doesn't need to do anything with it until the body is also received. In order to allow the underlying buffer to be used for reading the body, and also to avoid parsing the request twice, the app converts the various slices (method, path, headers) into integer indexes within the underlying buffer and then drops the
Request
in order to unborrow the buffer. Later on, the slices can be reestablished using the indexes.As of httparse 1.8, our app started failing due to slice locations potentially existing outside of the buffer, likely due to "GET" and "POST" now being returned as static strings.
In hindsight I suppose we were abusing the API. httparse never guaranteed the slices would always point within the buffer. It was just an easy assumption to make since httparse is known to do in-place parsing without copying. I'm not sure if anything should be changed in httparse and we will look at reworking our code. Posting this in case anyone else ran into the same issue.
The text was updated successfully, but these errors were encountered: