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

provide an error_code member #5

Closed
jonashaag opened this issue Apr 26, 2010 · 6 comments
Closed

provide an error_code member #5

jonashaag opened this issue Apr 26, 2010 · 6 comments

Comments

@jonashaag
Copy link

I can end parsing a message by returning some non-0 value. So if the parsing failed, I would like to see why it failed, hence, look at the return (error) code.

Please provide something like a error_code member in the http_parser struct.

@ry
Copy link
Contributor

ry commented Apr 26, 2010

you can see where it failed by looking at the result of http_parser_execute()

@jonashaag
Copy link
Author

wtf, that was fast. Doesn't http_parser_execute return the number of bytes parsed?

@ry
Copy link
Contributor

ry commented Apr 26, 2010

yes, but it exits immediately if there was an error. so if http_parser_execute() < sizeof(buf) then there was an error (or an Upgrade). You can use this to point out where the error was - which is perhaps more useful than an error code.

@jonashaag
Copy link
Author

hrm, I'd like to use the return values for indicating the reason why I made http-parser exit; for example after I got the request URL and figured out I want to answer with HTTP 404, it would be comfortable to simply return 404.

If I manually break parsing, I've got a reason to and I most probably want to communicate that reason back to the code that called http_parser_execute so that code can decide what steps to take next.

So please add this feature. :-)

@ry
Copy link
Contributor

ry commented Apr 26, 2010

You can communicate your state (or what action to take) to the code calling http_parser_execute() through your void *data object.

@ry
Copy link
Contributor

ry commented Jun 6, 2010

closing.

This issue was closed.
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