I’m having trouble with the TROWinInetHTTPChannel.
If I set the TargetURL to a URL that redirects to another URL (302 - Temporary unavailable) I get an EROInvalidStream exception with message "Invalid binary header. Either incompatible or not a binary message.
<?xml version="1.0" encoding="utf-8"?>
.<
.<
.<
.<
.<
.<
.<
.<<Operatio" while transferring files to server “MY-URL”."
If i change the TargetURL to the URL that i previously was redirected to everything works fine.
Any clues about waht might go wrong when the request is being redirected?
It is obviously nothing wrong with the Server-Side since it works fine if I access it without being redirected.
Let me explain what’s going on there. Any HTTP remote service request is POST. When WinInet sees a redirect replied to POST it thinks about the Post/Redirect/Get pattern and issues a GET request to the received location. GET http://localhost:8099/bin gives us the server RODL back and this data is passed to RO as if it is a remote service response.
The problem here is we cannot affect WinInet (yes, it is “shut up, we know what you really need”). But we have other HTTP client channels available. I’d use Indy TROIndyHTTPChannel. It handles redirects properly after this property is set:
Thanks for your explanation.
I try to avoid TROWinInet components but in this case we have customers with old client-versions. I was hoping to avoid upgrading them. But in this case it seems as there is no workaround.
We are changing the URL for our service. And we will inform our customers that they need to change URL in their configuration.
But until they have change it we still want the old URL to work, being redirected to the new URL. We cannot just change the DNS records in this case.
There is one more way to achieve the same: making a proxy server. Here is the sample. The only drawback here is you have to manually write a handler for every exposed method. But handlers are quite simple and it is feasible if the methods count is not too large.