question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specify host header and send request against IP

See original GitHub issue

Is there a way to specify host header and send request against IP similar to this:

txheaders = { 'User-Agent': UA, "Host": nohttp_url }
robots = urllib2.Request("http://" + ip  + "/robots.txt", txdata, txheaders)

Our main site has single IP and distinguish virtual sites via host header. There are multiple web servers behind load balancer. I need to run test against internal (particular web server) IP or external (load-balanced) IP

I guess, I can use custom DNS to map everything to IP I need, but workstation I run tests from is used for many other things…

Could somebody clarify why User-Agent header works, but Host is ignored, please? Is there another workaround without custom DNS?

I need smth. like: locust --host=http://IP --no-web

h = {
"Host": "my.name.com",
"User-Agent":"locust",
}
self.client.get("/", headers=h)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
aimer1124commented, Jun 20, 2017
h = """{
"Host": "my.name.com",
"User-Agent":"locust",
}
"""
self.client.get("/", headers=h)

Try this.

0reactions
divyatvcommented, Dec 12, 2019

I used to get 401 errors, while using python Locust for a load test- but wasn’t able to figure out how to send Authentication Type= Preemptive in the headers. But this clue helped and was able to figure out the solution.

h={‘Authorization’: ‘Basic PUTKEYHERE’} self.client.get("/<some api call uri> ", headers=h)

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Host Header - What is an HTTP Host Header injection?
The HTTP host header is a request header that specifies the domain that a client (browser) wants to access. This header is necessary...
Read more >
HTTP: Is an IP address allowed in the host header field?
So my first question is: If I program a HTTP server, should I implement a check, whether the client sends an IP address...
Read more >
Host - HTTP - MDN Web Docs
The Host request header specifies the host and port number of the server to which the request is being sent.
Read more >
How to add http host header in URL? - Server Fault
To get the first request the URL might be doom.myteams.myorg.net/https://myteams.myorg.net/config The Host should come from the URL and the GET ...
Read more >
What Is a Host Header? - ITPro Today
Introduced in HTTP 1.1, a host header is a third piece of information that you can use in addition to the IP address...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found