Can't modify response header in isapi extension

138 views Asked by At

I have an isapi extension that is returning an image file through WriteClient().

I need to return "Content-Type: image/jpeg" in the header (or else the calling app will not process the image)

So, I create a HSE_SEND_HEADER_EX_INFO structure and have member pszHeader = "Content-Type: image/jpeg\r\n\r\n"

before I issue WriteClient(), I call

ecb->ServerSupportFunction( ecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &newHeader, NULL, NULL );

The return from call to ServerSupportFunction() is TRUE (no need to call GetLastError())

However, my header information is put into the body and default headers are sent to client. This is the header sent to the client:

X-Cache: MISS from ip-172-18-8-226

Server: Microsoft-IIS/8.5
 X-Cache-Lookup: HIT from ip-172-18-8-226:3128
 Content-Length: NNN
 Date: Thu, 21 Sep 2017 14:32:38 GMT
 X-Powered-By: ASP.NET
 Content-Type text/html

Note that it does not change "Content-Type:" to "image/jpeg" but, instead, retains "Content-Type: text/html". Oddly, it puts my header information into the (that is, the 1st line of the body is "Content-Type: image/jpeg"...followed by the actual image data).

Note 1: I have tried HSE_SEND_HEADER_INFO and HSE_REQ_VECTOR_SEND. Both give same behavior.

Note 2: If I remove the WriteClient() call and just call ecb->ServerSupportFunction(), my return data is the default header that I can't seem to change followed by a single line (which is now the content body) of "Content-Type: image/jpeg"). So, this behavior IS NOT caused by sending header data through the call to WriteClient()

How am I to modify response header so that I can send modified "Content-Type:" ?

0

There are 0 answers