Giter Club home page Giter Club logo

Comments (6)

toland avatar toland commented on July 29, 2024

Yes, we drop the body when building a GET request with libcurl. I did some research on GET with a body this afternoon and I think it is more accurate to say that the HTTP spec does not preclude a body in a GET request, but neither does it specify the semantics for such a thing. I ran across this quote from Roy Fielding while researching the topic:

Server semantics for GET, however, are restricted such that a body,
if any, has no semantic meaning to the request. The requirements
on parsing are separate from the requirements on method semantics.

So, yes, you can send a body with GET, and no, it is never useful
to do so.

Given this I am inclined to leave Patron the way it is. I am, however, open to implementing more methods (such as the methods described in the WebDAV spec) if that would be useful.

~p

from patron.

mislav avatar mislav commented on July 29, 2024

Curl supports GET with body:

curl -X GET localhost:4567/echo -d name=mislav

That means it's supported with libcurl. The only reason why Patron doesn't support it because it explicitly chooses to block it. I don't think that's such a good call because the spec never explicitly says "Thou shalt not send body with GET requests"; it simply leaves this a gray area.

For an example of GET with body in the wild: elasticsearch

$ curl -XGET http://localhost:9200/twitter/_search?pretty=true -d '{
    "query" : {
        "range" : {
            "post_date" : {
                "from" : "2009-11-15T13:00:00",
                "to" : "2009-11-15T14:30:00"
            }
        }
    }
}'

This is actually a pretty good use case. It queries the search index but uses the body since the query might be too large to fit in a URL. The request is still idempotent and still can be HTTP-cached.

from patron.

toland avatar toland commented on July 29, 2024

I never disputed that libcurl supports GET with a body. I said "we drop the body when building a GET request with libcurl"; in other words Patron ignores the body when creating the request with libcurl. I am clearly aware of the technical issues.

While the spec doesn't explicitly forbid GET requests with a body, as Fielding makes clear the spec does not define server semantics for such a request. Therefore a server that implements some semantics for GET with a body is by definition implementing non-standard behavior. The above example is abusing GET for no clear benefit. If you really need to send a body for something like that use POST. That is what it is there for.

The bottom line is that I have limited time to devote to Patron and I am not going to spend it implementing corner-case features.

from patron.

pcarrier avatar pcarrier commented on July 29, 2024

Well, it's used by Elastic Search and ArchLinux's AUR API. Would you at least accept a patch?

from patron.

toland avatar toland commented on July 29, 2024

I already have: 4eaaf3e

from patron.

pcarrier avatar pcarrier commented on July 29, 2024

Thanks!

from patron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.