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
Solved

WinHTTP.WinHTTPRequest and the Content-Type field

Posted on 2011-03-06
6
3,212 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 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