Atozed Forums

Full Version: TIdHTTP Put Method
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am using Indy 10 version 10.6.2.0 on C++ Builder 6.0 Professional Edition ( Windows10 ).

I need to use the Put method of TIdHTTP, but it is sending headers before the stream of requests.

Code:
PUT ************* HTTP/1.1
// I need to put the stream here, before the following headers
Content-Length: 313
Host: 127.0.0.1:3004
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/3.0 (compatible; Indy Library)


How can I avoid those headers or at least put the headers I need before automatic headers ?

Thank you very much.
(08-27-2018, 03:39 PM)jjeffman Wrote: [ -> ]I need to use the Put method of TIdHTTP, but it is sending headers before the stream of requests.

As it should be, because that is how HTTP works.

(08-27-2018, 03:39 PM)jjeffman Wrote: [ -> ]
Code:
PUT ************* HTTP/1.1
// I need to put the stream here, before the following headers
Content-Length: 313
Host: 127.0.0.1:3004
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/3.0 (compatible; Indy Library)

How can I avoid those headers or at least put the headers I need before automatic headers ?

You cannot put a stream of data before request headers. What are you REALLY trying to accomplish? What is in your stream exactly? What is the server expecting the PUT request to look like exactly?

Are you, by chance, trying to send a chunked request (with a Transfer-Encoding: chunked request header), where the request contains trailing headers after the chunk data is finished? If so, TIdHTTP does not currently support sending a chunked request at this time (only reading chunked responses).
Hi Remmy,

I have solved this problem using a post of yours in another forum, where your answer to the question that was made there was to use CustomHeaders and an empty stream.

I am using "CustomHeaders" to put the headers I need and adding the JSON data in the Stream, so now all is working fine.

Thank you very much.