Solved

WinHTTP.WinHTTPRequest and the Content-Type field

Posted on 2011-03-06
6
3,343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA Vbscript  Issue 9 42
batch file or script 4 66
Login Script to pull users IP Phone from AD and then create a registry key in HKCU with that value 8 32
VB script help 23 50
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…
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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