awneil
June 14, 2015, 2:38pm
1
On my AirPi (SL8082T)
I took the standard http_get sample:
/* HTTP GET command */
http_ClientTestCtx.DataChannel = wip_getFileOpts (
http_ClientTestCtx.CnxChannel, /* session channel */
(ascii *) HTTP_STR_URL, /* requested URL */
http_ClientTestDataHandler, /* data handler */
&http_ClientTestCtx, /* context */
/* request headers */
WIP_COPT_HTTP_HEADER, "Accept", "text/html",
WIP_COPT_HTTP_HEADER, "Accept-Language", "fr, en",
WIP_COPT_END );
And modified it to do a PUT instead of GET:
static ascii content_length_str[80];
http_put_length = wm_strlen( http_put_content );
http_put_idx = 0;
wm_sprintf( content_length_str, "%d", (int)http_put_length );
http_ClientTestCtx.DataChannel = wip_getFileOpts (
http_ClientTestCtx.CnxChannel, /* session channel */
(ascii *) HTTP_STR_URL, /* requested URL */
http_ClientTestDataHandler, /* data handler */
&http_ClientTestCtx, /* context */
WIP_COPT_HTTP_METHOD, WIP_HTTP_METHOD_PUT,
/* request headers */
WIP_COPT_HTTP_HEADER, "Accept", "*/*",
WIP_COPT_HTTP_HEADER, "X-ApiKey", HTTP_STR_API_KEY,
WIP_COPT_HTTP_HEADER, "Content-Length", content_length_str,
WIP_COPT_END );
Note that I have included a ‘Content-Length’ header.
But The response from the Server is 411 Length Required :
[b]411 Length Required[/b]
[b]411 Length Required[/b]
nginx/1.1.19
What’s going on?
awneil
June 14, 2015, 2:46pm
3
No, using wip_put FileOpts() doesn’t make any difference.
Hi Awneil,
Have you resolved this issue yet?
davidc
July 13, 2015, 9:12am
6
Hiya,
Can you get access to your server access logs? I’m just wondering if there is more info in the server logs rather than the html response.
Also, can you make a dumb php file that simply reads the data stream (headers and body) and dumps it to a file? I would like to see exactly what your module is uploading … I’m wondering if the data is being encoded by the module, and thus the content length really is wrong. Also, are you counting the end of line (cr lf) fields in your content length?
Ciao, Dave
awneil
July 13, 2015, 10:54am
7
To be honest, I haven’t investigated further yet.
'fraid not - not my server.
Yes - that would be my next step …
The message is “411 Length Required ” - which suggests that the length is actually not present - rather than being wrong
www.w3.org/Protocols/rfc2616/rfc2616-sec10.html:
10 Status Code Definitions
:
:
10.4.12 411 Length Required
The server refuses to accept the request without a defined Content- Length. The client MAY repeat the request if it adds a valid Content-Length header field containing the length of the message-body in the request message.
w3.org/Protocols/rfc2616/rfc2616-sec10.html
which is not entirely clear that it may mean “present but wrong” in addition to just “not present” …
awneil
July 13, 2015, 11:00am
8
Thinking about it, I tested the request “manually” using curl; so I guess I could repeat that with a deliberately wrong length - and see if I get the 411 for that …