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

provide an error_code member #5

Closed

Description

@jonashaag

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.

Activity

  1. ry commented on Apr 26, 2010

    @ry
    Contributor

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

  2. jonashaag commented on Apr 26, 2010

    @jonashaag
    Author

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

  3. ry commented on Apr 26, 2010

    @ry
    Contributor

    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.

  4. jonashaag commented on Apr 26, 2010

    @jonashaag
    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. :-)

  5. ry commented on Apr 26, 2010

    @ry
    Contributor

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

  6. ry commented on Jun 6, 2010

    @ry
    Contributor

    closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions