HTTP Post reply 400

Hi,
I am trying to create a HTTP Post but I always get a reply "400 Bad Request: No Host Header".
I guess I know what it means, but I don't know how to overcome.

I have a inject and a function:

msg.payload = 'id=625&show=D_C_1_1~';
msg.headers = {};
msg.headers={
    'Content-Type': 'application/x-www-form-urlencoded'
};

return msg;

Then a http post request

grafik

The reply is:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"xml:lang="en" lang="en">
<head>
<title>Error</title>
</head>
<body>
<b>400 Bad Request: No Host Header</b>
<br/>
/mux_http
<br/>
</body>
</html>

That looks to me as if parts of the url are not submitted.

Any idea?
Regards
Kallewirsch

Hi all,
I go a reply on github.
Result:

msg.topic = 'Gruenbeck post';
msg.method = 'POST';
msg.url = 'http://f42240gb.example.com/mux_http';
msg.payload = 'id=625&show=D_A_1_2~';
msg.headers = {};
msg.headers={
    'Content-Length': '22',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Host': 'f42240gb.example.com'
};

return msg;

This now works!

I have searched the web very intensively the last days but did not find a hint in that direction.
I know, there are probably 100 parameters you can add to the HTTP-request an only an expert can find out where to put what - bu I am no expert in HTTP - realy not.

So this might help some other people with this as an expample for the HTTP-Request with "POST".

Thanks
Kallewirsch
Issue closed!

To repeat what I said in GitHub (aside from, please don't cross post questions in both places), the Host header is a fundamental part of an http request. You should not have to set it.

So we'll keep the issue open on GitHub so we can investigate why the header is missing for you.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.