Setting host header causes a python casting error
See original GitHub issueI get a TypeError
when trying to request a URL and passing a Host
header to it. I tried with quotes and without, but nothing works.
See the following example where prefixing m.
to the hostname causes an error:
$ http -v http://m.youtube.com Host:m.youtube.com
http: error: TypeError: Cannot mix str and non-str arguments
Compared to:
$ http -v http://m.youtube.com Host:youtube.com
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: youtube.com
User-Agent: HTTPie/0.9.6
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Content-Type: text/html
Date: Thu, 22 Sep 2016 12:53:56 GMT
Location: http://www.youtube.com/
Server: YouTubeFrontEnd
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
The same request with curl works properly so definitely looks like something’s off on httpie.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
Invalid HTTP_HOST header error? - Stack Overflow
When Django validates the host from the HTTP request it attempts to match it against the following regex which you can find in...
Read more >Exception Handling — Python 3.11.1 documentation
The functions described in this chapter will let you handle and raise Python exceptions. It is important to understand some of the basics...
Read more >Error handling in Azure API Management policies
Learn how to respond to error conditions that may occur during the processing of requests in Azure API Management.
Read more >NGINX settings - GitLab Docs
For example, to configure HTTP to HTTPS redirection for GitLab, ... you will need to tweak the proxy headers in order to avoid...
Read more >mod_headers - Apache HTTP Server Version 2.4
The normal mode is late, when Request Headers are set immediately before running the content generator and Response Headers just as the response...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue has been resolved in the requests library. https://github.com/kennethreitz/requests/issues/3597
Thanks @bbamsch !