TScHttpWebRequest and GetResponse Exception

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
jensgott
Posts: 2
Joined: Wed 03 Apr 2019 09:35

TScHttpWebRequest and GetResponse Exception

Post by jensgott » Wed 03 Apr 2019 09:42

I have a problem with TScHttpWebRequest.

When I call GetResponse from a webservices returning status code 403, I get an exception telling me that this code has been return. But I have no way of getting the data send with this status code?

If I call TScHttpWebRequest's ReadBuffer I only get what I did send

Is there anyway to avoid the GetResponse raise an exception, which is not a logical solution in my opion. Or at lease get the data send from the webservice?

ViktorV
Devart Team
Posts: 2692
Joined: Wed 30 Jul 2014 07:16

Re: TScHttpWebRequest and GetResponse Exception

Post by ViktorV » Wed 03 Apr 2019 14:06

When the server returned an error status 403 and there is some additional information, then to access this information, you can use the HttpException.ServerMessage property. For example:

Code: Select all

  try
    Response := Request.GetResponse;
  except
    on E: HttpException do
      if HttpException(E).StatusCode = scForbidden then
        s := HttpException(E).ServerMessage;
  end;

jensgott
Posts: 2
Joined: Wed 03 Apr 2019 09:35

Re: TScHttpWebRequest and GetResponse Exception

Post by jensgott » Thu 04 Apr 2019 08:10

Thank you - works great.

BTW: ServerMessage is not documentet in the help for HttpException

ViktorV
Devart Team
Posts: 2692
Joined: Wed 30 Jul 2014 07:16

Re: TScHttpWebRequest and GetResponse Exception

Post by ViktorV » Thu 04 Apr 2019 08:57

It is good to see that the problem has been solved.
Thank you for the information. We will add the necessary information in SecureBridge help in the next version of SecureBridge.
Feel free to contact us if you have any further questions about our products.

Post Reply