[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] HTTP/1.1 411 Length Required with httpapi v 1.35



Scott,

Thanks for the solution, it's working now. Just posting to forum the way I'm doing, in case anyone else face this issue.

InputMessage1= '<TrackFieldRequest USERID="xxxxxxxxx"> +                           
                <TrackID ID="yyyyyyyyyyyyy"></TrackID></TrackFieldRequest>'; 

                '&XML=' + InputMessage1 ;                                       

rc  =  http_req('POST'               
               : httpurl             
               : *omit               
               : ResponseMessage     
               : *omit               
               : InputMessage1       
               : 'application/xml') ;

Thanks,
Pargat 




On Wed, May 31, 2017 at 2:41 AM, Scott Klement <sk@xxxxxxxxxxxxxxxx> wrote:
Pargat,

HTTPAPI needs to know whether whether to send a request body or not.  The way it determines this is by whether you pass *NULL for the data or not.  If you pass *NULL, it will not send a request body. 

If you want it to send a request body, but you want the length of that request body to be 0, then you should pass a non-null value for the data, but pass the length=0.  This will do what you want.

You may be thinking "it should just know I want a request body because I'm doing a POST (or PUT?) request".  But, I don't want to hard-code a list of methods that do/don't send request bodies because I want things to be generic.  People are frequently adding new methods to the HTTP protocol for special/specific purposes, and I don't want to hard-code them all into HTTPAPI.  Instead, I want you to be able to specify any method, and control for yourself whether it does or doesn't have a request body.  That way, when new methods are released, they'll work without any changes to HTTPAPI.

So -- it's very simple.  Pass a non-null value for the post/put data, and pass length=0, and it will do what you want.

-SK




On 5/30/17 2:11 PM, Pargat Singh wrote:
Hi Scott,

I see this issue was raised in early Feb this year and you added the fix in release 1.34. But I'm still facing same issue in version 1.35.

I see you changed line 404 as pePostDataLen >= 0 but in my case pePostData and pePostProc also shows null so it never turn on flag for wwSendReqBody and I'm getting HTTP/1.1 411 Error.

When I change flag wwSendReqBody to *ON in debug, then it works. Please advise if I can add any additional condition to handle this scenario.

0404.00      c                   if        pePostDataLen >= 0 and                           
0405.00      c                             (pePostData<>*null or pePostProc<>*null)         
0406.00      c                   eval      wwSendReqBody = *on                              
0407.00      c                   endif                                                      

Change Log:
 Changes to version 1.34 from 1.33                                    
   - If a procedure or non-null pointer is provided for "upload" data 
       (i.e. POST, PUT or other stream upload data) but data length=0,
       then send a zero-length request body. Omitting Content-Length  
       on a PUT/POST request causes "411 Length Required" on some     
       servers. (Broken since 1.24BETA15)          



Thanks,
Pargat                   




--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi


-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi