HTTP PUT Not Working

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:

What’s going on?

Version info:

No, using wip_putFileOpts() doesn’t make any difference.

Hi Awneil,

Have you resolved this issue yet?

No - 'fraid not.

:frowning:

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

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 :question:

which is not entirely clear that it may mean “present but wrong” in addition to just “not present” … :question:

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 …