WinHTTP.WinHTTPRequest and the Content-Type field

I need urgent help with the following:

An VBScript applications uses WinHTTP.WinHTTPRequest.5.1 to send data to some server via the HTTP protocol.
It worked fine on Server 2003 and Windows XP 32 bit.
The machine on which the application should run from now is Windows Server 2008R2 64 bit.
It turned out the app not working on the 2008 because the WinHTTP.WinHTTPRequest.5.1 object always adds the "Content-type" HTTP header field
and for some reason the server fails when the header contains that field.

How to tell the WinHTTP.WinHTTPRequest.5.1 object to not to add the  "Content-type"  field ???
Old WinHTTP.WinHTTPRequest.5 object does not add that field!

I tried to manually  register ( using regsvr32 ) an old  WinHTTP.WinHTTPRequest.5 object which I took from a Windows XP machine (as the file winhttp5.dll).
I worked a little, but then stopped working with the message "Out of Memory" on the CreateObject() call.
I can see the object creates a file C:\Temp\DebugTrace.log with the text inside:
*** Software Failure: No TLS available ***
How can I make it work properly ???

On the 2003 machine where everything worked fine I see the WinHTTP.WinHTTPRequest object is not mentioned in the registry
(some like HKEY_CLASSES_ROOT\CLSID\{2087c2f4-2cef-4953-a8ab-66779b670495} ), but instead it located in the windows\WinSxS
folder.
If I copy the object file from the 2003 server how can I register it properly then on 2008 ???









LVL 19
zc2Asked:
Who is Participating?
 
McNeticConnect With a Mentor Commented:
Quoted from above linked article:

The SetRequestHeader method enables the calling application to add or delete an HTTP request header prior to sending the request. The header name is given in Header, and the header token or value is given in Value. To add a header, supply a header name and value. If another header already exists with this name, it is replaced. To delete a header, set Header to the name of the header to delete and set Value to NULL.

But as the header is set by default, maybe it's not possible to delete it. I don't know that, and can't give further assistance regarding this. But, as I already pointed out, I think it must be possible to get the server to respond if the correct header value is set.
0
 
McNeticCommented:
I'd suspect it is not easily, if at all, possible to port the WinHTTPRequest.5 object to the 2008 Server. It should, however, be possible to get the whole thing working with the 5.1 object. You can try to manually set the content-type request header like this:

objHTTP.SetRequestHeader "Content-type", "text/html"

Open in new window


Try with the content-type you are actually trying to send. Given the correct content type, a given server should not fail to process the request correctly.

It should even be possible to delete the header:

objHTTP.SetRequestHeader "Content-type", NULL

Open in new window

0
 
zc2Author Commented:
Thank you for the answer.

My question was - how can I disable the Content-Type header, exclude it from the HTTP completely, not how to replace it to my own value. With the second, there is no any problem.

I tried to pass such values as Empty and Null as the content-type header value.
In the first case the WinHTTP creates the "Content-Type: text/plain" (and it does the same if I don't call the setRequestHeader( "Content-Type", ... ) at all).
In the second case I got an error saying: "Type mismatch".
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
McNeticCommented:
I'm sorry that deleting the content-type header does not seem to work. According to MSDN, it should be possible to delete a header, but I can't find a vb example or an explanation how to do it in vb.

However, I think it should be possible to get the whole thing working when setting the correct Content-type header that the server will accept.
0
 
zc2Author Commented:
Hm, I've read the article you mentioned, but I did not see there anything about how to delete a header. Is it possible? If it's not, that's OK, I just need to know that for sure and will not try to find a solution by that approach anymore.

0
 
zc2Author Commented:
Thanks, following your advice, I contacted the server party and they fixed the error the server issued when the Content-Type was present in the headers.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.