Skip to content

r.http returns None/null for HEAD requests #3371

Open
enterstudio/rethinkdb
#26

Description

@larkost

For r.http(method="HEAD") requests we are currently returning None/null since that is the body of the result. While that is Ok for people who wish to use HEAD requests as a form of PING, it is not very useful for those who might be using it for grabbing things like ETags or Content-Disposition headers.

This is obviously not a priority (since no one has asked for it), but we should probably parse the headers and return them as an object.

Activity

  1. added this to the backlog milestone on Nov 25, 2014
  2. tarqd commented on Sep 19, 2015

    @tarqd

    +1 for this, it'd be awesome if we could get access to the Etags/headers. Would make it possible to have the query store the etag and send a proper If-None-Match header right from rethinkdb. It'd be nice to have one less step

  3. Tryneus commented on Jan 8, 2016

    @Tryneus
    Member

    I think we should make this change, and a quick look at the code shows it would be dead simple. I am concerned that the change is not backwards compatible, though. Luckily, since r.http is non-deterministic, we don't have to worry about breaking index compatibility, but we would still need to discuss this.

  4. modified the milestones: subsequent, backlog on Jan 8, 2016
  5. tarqd commented on Jan 8, 2016

    @tarqd

    Could add an option such as "{return_headers: true}" to enable new functionality

  6. danielmewes commented on Jan 8, 2016

    @danielmewes
    Member

    @ilsken That's certainly an option.

    It would probably be nice if we could return the headers for non-HEAD requests as well. I'm not sure how that should look like when getting a stream from r.http though.

  7. marshall007 commented on Jan 8, 2016

    @marshall007
    Contributor

    @danielmewes one option would be to create a new http_response pseudotype. The specifics of the API would need to be discussed, but it would give you guys a place to throw any of the HTTP request/response metadata (and not just headers). Since the drivers could just unwrap the psuedotype value (response body) when it gets deserialized, the server could return everything by default but not introduce a breaking change to user code. However, as you mentioned, things would still be tricky when the response is a stream.

  8. danielmewes commented on Jan 11, 2016

    @danielmewes
    Member

    @marshall007 Yeah I briefly thought about that too. That's probably the correct way for solving this.
    It's also a fair bit of work to implement though, and we have to figure out the exact semantics of how the type can be cast into other types, and how its "fields" are accessed.
    I think we might want to pick a simpler solution for the time being.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions