Code Monkey home page Code Monkey logo

Comments (8)

clintongormley avatar clintongormley commented on May 17, 2024

Yes.

from elasticsearch-definitive-guide.

lukas-vlcek avatar lukas-vlcek commented on May 17, 2024

Clint, I thought this might be rather limitation of XMLHttpRequest object which is to my knowledge not part of JavaScript language specification but rather is provided in form of API in specific environments (such as web browsers).

from elasticsearch-definitive-guide.

clintongormley avatar clintongormley commented on May 17, 2024

Ah right, i see what you mean. That said, do you know of any implementations of javascript which do support GET with body?

from elasticsearch-definitive-guide.

lukas-vlcek avatar lukas-vlcek commented on May 17, 2024

IMO it is mixing of topics. JavaScript has nothing to do with GET. It is the web client or library that does the GET. May be there is a Node library that allows to do GET with body (I am not using it but may be Unirest allows that)? Or I can imagine calling Java API from JavaScript that would do it (so technically I would be using still JavaScript language and some API would allow me to do GET with body).

You can perfectly leave it as it is, I think many people will understand what you mean. It is that it just hit me into eyes ("... wait a sec. is this correct?"). But you know.. I might be oddball πŸ˜„

from elasticsearch-definitive-guide.

clintongormley avatar clintongormley commented on May 17, 2024

:)

from elasticsearch-definitive-guide.

lukas-vlcek avatar lukas-vlcek commented on May 17, 2024

Funny.
I looked into some Node http related libraries and surprisingly they often explicitly make sure they do not include body into request when doing GET. It is hardcoded into them, it is not by design of JavaScript language but rather practice. But is there actually any reason for this? I am afraid there might be one. The problem could be that HTTP RFC does not explicitly state how servers should treat GET requests with body. As a result some servers can simply reject GET requests with body.

curl -X GET 'http://google.com'
vs.
curl -X GET 'http://google.com' -d ' '
// using telnet it is even more interesting

If servers can do this so can proxy servers. And if this is really matter of server (or proxy) implementation why would only JavaScript HTTP clients be afraid of doing GET requests with body?

But in any case I think it might be valuable to elaborate this a little bit more in the book. I wouldn't be surprised if users of non-JavaScript clients would be hit by this as well (for example because these was very strict proxy in their way).

from elasticsearch-definitive-guide.

clintongormley avatar clintongormley commented on May 17, 2024

Yeah I agree we need to add some explanation. We often get people saying "you can't send a body with a GET" or that it is wrong. We should probably explain our justification for doing so, and the various workarounds available.

from elasticsearch-definitive-guide.

mitar avatar mitar commented on May 17, 2024

Why not saying "Ajax calls don’t allow request bodies with a GET request."?

from elasticsearch-definitive-guide.

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.