Board index » delphi » Send a stream in a (indy) HTTP request?

Send a stream in a (indy) HTTP request?

question:

Is it possible to send a binary stream to my CGI/ISAPI ?

Something like uploading a file thru a stream. I know it's possible to send
a stream in a response but i really want to do it in a request.

/David

 

Re:Send a stream in a (indy) HTTP request?


Yes, You have to organize this as POST request to your CGI.

Doychin

Quote
"David Bezjak" <davi...@sigma.se> wrote in message

news:8vm2uv$b3k2@bornews.inprise.com...
Quote
> question:

> Is it possible to send a binary stream to my CGI/ISAPI ?

> Something like uploading a file thru a stream. I know it's possible to
send
> a stream in a response but i really want to do it in a request.

> /David

Re:Send a stream in a (indy) HTTP request?


You probably mean something like:

IdHTTP1.post('http://127.0.0.1/scripts/project1.exe/send', bstream,
cstream);

Where bstream and cstream are TStringStream in my test case. How do i get
hold of bstream on the sever side CGI. I must be missing something
fundamental here but on the server side you have response.SendStream to send
a stream to the client but nothing like "request.recivestream" to recive a
stream.
How do you recive the stream in the server side CGI?

/David

Quote
Doychin Bondzhev <doic...@5group.com> wrote in message

news:3a1e96a8_1@dnews...
Quote
> Yes, You have to organize this as POST request to your CGI.

> Doychin

> "David Bezjak" <davi...@sigma.se> wrote in message
> news:8vm2uv$b3k2@bornews.inprise.com...
> > question:

> > Is it possible to send a binary stream to my CGI/ISAPI ?

> > Something like uploading a file thru a stream. I know it's possible to
> send
> > a stream in a response but i really want to do it in a request.

> > /David

Re:Send a stream in a (indy) HTTP request?


The post stream have to look like:

-----------------------------7cf87224d2020a
Content-Disposition: form-data; name="file1"; filename="c:\abc.txt"
Content-Type: text/plain

abc 123
abc 1234
-----------------------------7cf87224d2020a
Content-Disposition: form-data; name="Submit"

Submit
-----------------------------7cf87224d2020a--
and the abc part is where you have to put the data from the stream.

In the Request.ContentType you have to put this
'multipart/form-data; boundary=-----------------------------7cf87224d2020a';

In the normal case the number(7cf87224d2020a) is different all the time but
if you are shoure that it will not apear in the stream you trying to send
then you can use it in any post request.

Doychin

Quote
"David Bezjak" <davi...@sigma.se> wrote in message

news:8vm7go$ft71@bornews.inprise.com...
Quote
> You probably mean something like:

> IdHTTP1.post('http://127.0.0.1/scripts/project1.exe/send', bstream,
> cstream);

> Where bstream and cstream are TStringStream in my test case. How do i get
> hold of bstream on the sever side CGI. I must be missing something
> fundamental here but on the server side you have response.SendStream to
send
> a stream to the client but nothing like "request.recivestream" to recive a
> stream.
> How do you recive the stream in the server side CGI?

> /David
> Doychin Bondzhev <doic...@5group.com> wrote in message
> news:3a1e96a8_1@dnews...
> > Yes, You have to organize this as POST request to your CGI.

> > Doychin

> > "David Bezjak" <davi...@sigma.se> wrote in message
> > news:8vm2uv$b3k2@bornews.inprise.com...
> > > question:

> > > Is it possible to send a binary stream to my CGI/ISAPI ?

> > > Something like uploading a file thru a stream. I know it's possible to
> > send
> > > a stream in a response but i really want to do it in a request.

> > > /David

Re:Send a stream in a (indy) HTTP request?


I forgot to say thank you, but i found a working example at
http://www.matlus.com

Anyway, thank you!

/David

Quote
Doychin Bondzhev <doic...@5group.com> wrote in message

news:3a1f7895_1@dnews...
Quote
> The post stream have to look like:

> -----------------------------7cf87224d2020a
> Content-Disposition: form-data; name="file1"; filename="c:\abc.txt"
> Content-Type: text/plain

> abc 123
> abc 1234
> -----------------------------7cf87224d2020a
> Content-Disposition: form-data; name="Submit"

> Submit
> -----------------------------7cf87224d2020a--

> and the abc part is where you have to put the data from the stream.

> In the Request.ContentType you have to put this
> 'multipart/form-data;

boundary=-----------------------------7cf87224d2020a';

- Show quoted text -

Quote

> In the normal case the number(7cf87224d2020a) is different all the time
but
> if you are shoure that it will not apear in the stream you trying to send
> then you can use it in any post request.

> Doychin

> "David Bezjak" <davi...@sigma.se> wrote in message
> news:8vm7go$ft71@bornews.inprise.com...
> > You probably mean something like:

> > IdHTTP1.post('http://127.0.0.1/scripts/project1.exe/send', bstream,
> > cstream);

> > Where bstream and cstream are TStringStream in my test case. How do i
get
> > hold of bstream on the sever side CGI. I must be missing something
> > fundamental here but on the server side you have response.SendStream to
> send
> > a stream to the client but nothing like "request.recivestream" to recive
a
> > stream.
> > How do you recive the stream in the server side CGI?

> > /David
> > Doychin Bondzhev <doic...@5group.com> wrote in message
> > news:3a1e96a8_1@dnews...
> > > Yes, You have to organize this as POST request to your CGI.

> > > Doychin

> > > "David Bezjak" <davi...@sigma.se> wrote in message
> > > news:8vm2uv$b3k2@bornews.inprise.com...
> > > > question:

> > > > Is it possible to send a binary stream to my CGI/ISAPI ?

> > > > Something like uploading a file thru a stream. I know it's possible
to
> > > send
> > > > a stream in a response but i really want to do it in a request.

> > > > /David

Other Threads