Solved

WinHTTP.WinHTTPRequest and the Content-Type field

Posted on 2011-03-06
6
3,060 Views
Last Modified: 2013-11-18
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 ???









0
Comment
Question by:zc2
  • 3
  • 3
6 Comments
 
LVL 8

Expert Comment

by:McNetic
ID: 35081749
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
 
LVL 18

Author Comment

by:zc2
ID: 35089041
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
 
LVL 8

Expert Comment

by:McNetic
ID: 35099866
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 18

Author Comment

by:zc2
ID: 35100683
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
 
LVL 8

Accepted Solution

by:
McNetic earned 500 total points
ID: 35106415
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
 
LVL 18

Author Closing Comment

by:zc2
ID: 35109231
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now