GithubHelp home page GithubHelp logo

Header host missing port about needle HOT 8 CLOSED

tomas avatar tomas commented on July 19, 2024
Header host missing port

from needle.

Comments (8)

tomas avatar tomas commented on July 19, 2024

Hey Boris,

I think we had this but at some point it was removed. Are you sure the Host header can or should include the port as part of its value? AFAIK the port is only used for establishing the connection to that specific port on a server, and has nothing to do with the Host itself.

from needle.

Alexander-Boris-de-Pfeffel-Johnson avatar Alexander-Boris-de-Pfeffel-Johnson commented on July 19, 2024

Hi Tomas!

Thanks for the response

I think it should be in some cases, am no expert in this field but dug up some spec from w3

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

"A "host" without any trailing port information implies the default port for the service requested (e.g., "80" for an HTTP URL)"

Unfortunately this slight edge case is an issue am bumping into

from needle.

tomas avatar tomas commented on July 19, 2024

Would you mind sharing the code that's giving you trouble, so I can reproduce the bug?

from needle.

Alexander-Boris-de-Pfeffel-Johnson avatar Alexander-Boris-de-Pfeffel-Johnson commented on July 19, 2024

Sorry for the long delay. Please excuse the rather noobish code below (with a funky infinite loop). Have tested it in the context on my app, but it should still work externally. The first time, from a browser, will show the headers.host as ''localhost:8081". The second time around from needle will show just "localhost".

express().all("", function (req, res) {

    console.log("Host is... " + req.headers.host);

    var url = "http://localhost:8081" ;

    needle.get(url, {}, function() {});

}

express().listen(8081)

Hopefully this should be enough to get the gist, but I think the port will be missing in whatever way the original needle command is made

from needle.

tomas avatar tomas commented on July 19, 2024

Hey Boris, sorry for the delay mate. What do you mean by first and second time? Because of a redirect?

from needle.

Alexander-Boris-de-Pfeffel-Johnson avatar Alexander-Boris-de-Pfeffel-Johnson commented on July 19, 2024

Sorry, the needle request will loop back into the same code. So the first time the context is a standard call to node, the second time will be the needle get request. First time the host contains the port, the second time from needle the host does not contain the port

from needle.

tomas avatar tomas commented on July 19, 2024

Ok sir, just tested and fixed it. Pushing 0.6.1 as we speak... Thanks again for reporting!

from needle.

Alexander-Boris-de-Pfeffel-Johnson avatar Alexander-Boris-de-Pfeffel-Johnson commented on July 19, 2024

Hey no problem! Mucho thanks for taking the time to chat and fix it :)

from needle.

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.