#1 2016-05-17 22:28:24

macc2010
Member
Registered: 2015-12-28
Posts: 8

THttpApiServer how to set HTTP/1.0 as response in the OnRequest event

I have created a vcl form application and created an instance of THttpApiServer class. In the OnRequest event I would like to set the version of the response to set it as HTTP/1.0 instead of HTTP/1.1.

For example, when I receive a request in this format : GET /../jpg/image.cgi HTTP/1.1 .....
I would like to response with : HTTP/1.0 200 OK .... Content-Type: image/jpeg ....

Thank you and best regards.

Offline

#2 2016-05-18 11:54:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: THttpApiServer how to set HTTP/1.0 as response in the OnRequest event

Set the appropriate output header.

Offline

#3 2016-05-18 18:31:23

macc2010
Member
Registered: 2015-12-28
Posts: 8

Re: THttpApiServer how to set HTTP/1.0 as response in the OnRequest event

ab wrote:

Set the appropriate output header.

Thank you, but in the OnRequest procedure I have the Ctxt: THttpServerRequest parameter. I have tried to set the Ctxt.OutCustomHeaders to HTTP/1.0 200 OK and Content-Type: image/jpeg but it does not work, I have sniffed the result and it always return HTTP/1.1 200 OK ..., I do not know how to set the output header. I have stopped the code when I set Result := 200 and followed the code line by line until the execution code return to the procedure THttpApiServer.Execute and I observed that the code arrives until :

EHttpApiServer.RaiseOnError(hSendHttpResponse,Http.SendHttpResponse(fReqQueue,Req^.RequestId,0,Resp^,nil,bytesSent,nil,0,nil,fLogData));

And in the Req^.Version.MajorVersion is 1 and Req^.Version.MinorVersion is 1, so I suspect that the HTTP/1.1 200 OK is responsed by the http.sys because I do not see it in any structure of the Req^ pointer.

Can you help me to set the appropiate header?.

Thank you and best regards.

Offline

#4 2016-05-19 05:52:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: THttpApiServer how to set HTTP/1.0 as response in the OnRequest event

Only put headers in the output header. The HTTP answer is not to be put as part of the headers.

Offline

Board footer

Powered by FluxBB