Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

WinHTTP.WinHTTPRequest and the Content-Type field

Posted on 2011-03-06
6
Medium Priority
?
3,659 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 19

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 19

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 2000 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 19

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

886 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