Header name must be a valid HTTP Token (colon in header)
See original GitHub issueSummary
I got the error
[TypeError: Header name must be a valid HTTP Token [":authority"]]
Simplest Example to Reproduce
var request = require('request');
var options = {
url: '----',
headers: {
':authority': 'www.site.com',
':method': 'GET',
':scheme': 'https',
'referer': 'https://site.com',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36'
}
};
function callback(error, response, body) {
if (!error && response.statusCode === 200) {
console.log(body);
}
if (error) {
console.log(error);
}
}
request(options, callback);
Expected Behavior
I want to execute request with “:authority” header
Current Behavior
It doesn’t work.
Possible Solution
Add a flag use raw headers
and pass headers as is.
Context
Plain nodejs.
Your Environment
software | version |
---|---|
request | 2.81.0 |
node | v5.10.1 |
npm | 5.3.0 |
Operating System | mac os 10.12.6 |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:22
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Header name must be a valid HTTP token ["Authorization "] in ...
There should be an empty line break between the header (content-type: application/json) and the request payload/data.
Read more >Header name must be a valid HTTP token - Postman community
Colon is an invalid character for the HTTP header as per HTTP standards given in RFC822. There is a discussion on stack overflow...
Read more >Header name must be a valid HTTP token ["{"] #430 - GitHub
I had a previous simple test file that was working I tried to add a couple of requests in the same file but...
Read more >postman header name must be a valid http token
postman header name must be a valid http token. You have to fetch the CSRF Token by making a GET Request: Header: "XSRF-TOKEN"...
Read more >Error: Header name must be a valid HTTP token : r/flask - Reddit
I am new to Flask but when I am using PostMan to call a Python service running on Win10, this is the error...
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
@Freyert I don’t agree that this is a solution because it is not guaranteed that this API is under our control. At least this should be configurable. Many of us will want to be able to request APIs that do not adhere perfectly to IETF standards.
Your API has to be fixed:
https://tools.ietf.org/html/rfc7230#page-22