Jump to content
Carsten Eider

Save http-request to stream and read response from stream

Recommended Posts

Within a governmental projet there is a strange requirement I am trying to solve ICS.

 

We have to set up a complete http-request, such as get or post, with multiple headers, a content-type and so on.

But now I would like to get the request as a string or write it into a stream without sending it to a server over tcp.

 

Vice versa, I would like to read the response to the request from before out of a stream or a string.

 

Why do we have to do this? The original request has to be encrypted in a non standard-way and sent do a special server, which will decrypt the request, do is work, create a encrypted response and send this back to us.

 

Any ideas how we could implement this requirement?

Share this post


Link to post

The short answer is not easily with the ICS HTTP client components, they don't built a request nor buffer a response before processing it. 

 

The 'proper' solution would be to use the ICS proxy component as an intermediary to handle the encryption, which does give access to headers and content, but would still need changes since it would ignore the encrypted reply.

 

If you are only taking to a specific server with limited requirements and error handling, it would be easier to write your own HTTP client

 

I wrote a simple application 'Simple TCP Client Testing, ie HTTP headers' that uses the TIcsIpStrmLog component to send a simple HTTPS request to a server repeatedly, for heavy testing.  TIcsIpStrmLog expects to send and receive text lines as used by most protocols, if your encrypted headers and content arr binary, you would need to use a simple TWSocket instead.

 

Angus

 

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
×