DMTF / Redfish-Mockup-Server

A simple Python 3.4 program that can be copied into a folder at the top of any Redfish mockup and can serve Redfish requests on the specified IP/port.
Other
72 stars 37 forks source link

Content-Length header does not get generated/send #83

Closed Flow86 closed 3 years ago

Flow86 commented 3 years ago

Hi,

I tried to use the Redfish-Mockup-Server with a mockup I created with Redfish-Mockup-Creator, but ran into some problems with my HTTP client by Chilkat (3rdparty library).

When trying to get a response from the mockup server, I succesfully retrieve the response but without body. Chilkat stopped reading the body after the headers since neither Transfer-Encoding nor Content-Length was specified.

As far as I understood the HTTP RFCs correctly (but I could be wrong of course!) - you either have to specify a Content-Length or Transfer-Encoding: chunked for HTTP 1.1 responses?

After quick&dirty hacking the Content-Length header in in "None-Headerfile-Response-Mode" it worked for me.

Can you add the Content-Length header for responses in general?

mraineri commented 3 years ago

Do you mind pointing to which section in the HTTP 1.1 RFCs you're looking at? I'm looking at section 3.3.2 of RFC7230 and there are a lot of optional things you can do with Content-Length, but the only mandatory thing I see is when the body is empty, the header must be present with the value of 0.

mraineri commented 3 years ago

Although in general, your branch looks good; I think it's very reasonable to expect a Content-Length header since it's a pretty trivial thing to support.

Flow86 commented 3 years ago

Do you mind pointing to which section in the HTTP 1.1 RFCs you're looking at? I'm looking at section 3.3.2 of RFC7230 and there are a lot of optional things you can do with Content-Length, but the only mandatory thing I see is when the body is empty, the header must be present with the value of 0.

I seem to have misread the rfc. It states only SHOULD not MUST. So without Content-Length its quiet right. So probably I report it to Chilkat too ;-)

mraineri commented 3 years ago

Thanks for confirming! Yes, please give this feedback to Chilkat, but we can accept your proposed change since it does add goodness to the server in an easy manner.

mraineri commented 3 years ago

@Flow86 feel free to open a pull request from that branch you've made; we should be able to accept it formally later this week.