Skip to content

How to get HTTP verb? (GET, POST, PUT, HEAD, PATCH) #37

Description

@SamuelMarks

The closest I've gotten is the header output (https://github.com/SamuelMarks/node.native/blob/master/routes.h#L54):

$ http localhost:8080/headers
HTTP/1.1 200 OK
Content-Length: 141
Content-Type: application/json

{
    "headers": [
        {
            "Accept": "*/*"
        }, 
        {
            "Accept-Encoding": "gzip, deflate, compress"
        }, 
        {
            "Host": "localhost:8080"
        }, 
        {
            "User-Agent": "HTTPie/0.8.0"
        }
    ]
}

How do I get the HTTP verb?

Activity

  1. sebjameswml commented on Apr 9, 2014

    @sebjameswml
    Contributor

    Hi there.

    My fork of node.native adds the ability to get the HTTP body (the body of your POST).

    I think you could get the HTTP method by adding code in client_context::parse which will get the method from the http_parser - this has a method attribute which is set in http_parser_execute(). http_parser is one of node.native's submodules.

    Cheers,

    Seb

  2. sebjameswml commented on Apr 13, 2014

    @sebjameswml
    Contributor

    Hi Samuel, how did you get on with this one?

  3. SamuelMarks commented on Apr 13, 2014

    @SamuelMarks
    Author

    Didn't get around to it; TBH: I have moved away from C++ now for my web development, namely due to:

    • Segfault when using JSON() in routes.h
    • Linker errors when separating routes.h into routes.h and routes.cc
    • No built-in access to HTTP verbs
    • CMake build not included
  4. sebjameswml commented on Apr 13, 2014

    @sebjameswml
    Contributor

    Fair enough - you have to do a bit of hacking to use node.native, and that won't appeal to everyone. If you could close this issue, that'd be good.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions