Jump to content
xauxag

a icsv858 TSslHttpRest bug

Recommended Posts

version icsv858

unit OverbyteIcsHttpProt

procedure THttpCli.GetHeaderLineNext;

Line 3056:   if Field = 'location' then begin { Change the URL ! }

 

I think is a bug,

Based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201

The HTTP 201 Created success status response code indicates that the request has succeeded and has led to the creation of a resource.

So with Fstatuscode = 201 , there can be a location line in the http header as a normal response

 

Here is a example,

when I send a post to the server,the server response with a location line, but it was taken as a redirection ,so ICS resend the post to the new llocation again :

 

Connected to: api-fxtrade.oanda.com
> POST /v3/accounts/001-004-********-002/orders HTTP/1.1

...
api-fxtrade.oanda.com SSL Connected OK with TLSv1.2, cipher DHE-RSA-AES256-GCM-SHA384, key auth RSA, key exchange DH, encryption AESGCM(256), message auth AEAD
...

< HTTP/1.1 201 Created

< Location: https://api-fxtrade.oanda.com/v3/accounts/001-004-******-002/orders/240
< RequestID: 42647542696837564
= https://api-fxtrade.oanda.com/v3/accounts/001-004-******-002/orders Redirected to: https://api-fxtrade.oanda.com/v3/accounts/001-004-******-002/orders/240
Connected to: api-fxtrade.oanda.com
> POST /v3/accounts/001-004-******-002/orders/240 HTTP/1.1

 

ResponseRaw:{"errorMessage":"POST not allowed for endpoint."}

 

I change the code to

 

if (Field = 'location') and (FStatusCode <> 201)  then begin { Change the URL ! }

 

The reponse is OK

 

So please check.

 

Share this post


Link to post

Thanks, 201 Created is used a lot with REST, the Location code already has lots of special cases and I guess we need another.

 

Angus

 

Share this post


Link to post

Further to my last comment, I'm not going to change the code at the moment.  If you specifically want to ignore the Location: header for an API request, set property FollowRelocation to false. 

 

This is what the TSslX509Certs component does making REST requests which return Location: headers for responses 201 and 409. 

 

Angus

 

Share this post


Link to post
On 1/3/2020 at 6:44 PM, Angus Robertson said:

TSslX509Certs

OK ,that's for your reply

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×