winhttp

Send User-Agent through CONNECT and POST with WinHTTP?

…衆ロ難τιáo~ 提交于 2019-12-04 02:17:53
问题 I'm trying to POST to a secure site using WinHttp, and running into a problem where the User-Agent header isn't being sent along with the CONNECT. I am using a lightly-modified code sample from MSDN: HINTERNET hHttpSession = NULL; HINTERNET hConnect = NULL; HINTERNET hRequest = NULL; WINHTTP_AUTOPROXY_OPTIONS AutoProxyOptions; WINHTTP_PROXY_INFO ProxyInfo; DWORD cbProxyInfoSize = sizeof(ProxyInfo); ZeroMemory( &AutoProxyOptions, sizeof(AutoProxyOptions) ); ZeroMemory( &ProxyInfo, sizeof

WScript.CreateObject crashes Windows Scripting Host when event handler prefix is specified for WinHTTPRequest

时间秒杀一切 提交于 2019-12-04 01:59:59
问题 According to the MSDN documentation WinHTTPRequest has four event handlers which should be accessible by specifying an event handler prefix. Unfortunately, doing so causes Windows Scripting Host to crash. The following code crashes Windows Scripting Host: Set oHTTP = WScript.CreateObject( "WinHttp.WinHttpRequest.5.1", "oHTTP_" ) This code works just fine: Set oHTTP = WScript.CreateObject( "WinHttp.WinHttpRequest.5.1" ) Any thoughts as to why? 回答1: It's not part of the specification in any way

Certificate pinning with WinHTTP API

你。 提交于 2019-12-03 15:03:48
问题 Is it possible to implement certificate pinning using the Win32 WinHTTP API, and if so how? I.e. how can I check the returned server certificate against a 'known good' one, preferably without having to permanently write the cert into the local certificate store. 回答1: (inspired by jww's answer) Firstly I found this page to be excellent background reading about pinning and the choice between certificate and public key pinning. I implemented certificate pinning using WinHTTP API as follows:

How to make a POST request to a page that may redirect to a login page

◇◆丶佛笑我妖孽 提交于 2019-12-03 09:13:06
I am using a macro in Outlook VBA to submit a file via POST to a URL: Set http = New WinHttp.WinHttpRequest http.Open "POST", UrlToPostTo, False 'True ' http.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" http.setRequestHeader "Content-Type", "multipart/form-data; " http.Send data My problem is the page that will accept the request (a file upload page, in this case) is protected by authentication - the initial request for it above will return a login page instead of the page itself. I have tried to detect if the login page appears and if so, post the

VBA - Go to website and download file from save prompt

不问归期 提交于 2019-12-03 08:43:22
I've been spending the last few hours trying to figure out how to save a file onto the computer using VBA. The code template below that I found on another forum seems promising, except when I go to the desktop to access it, the .csv file has what looks like the page's source code instead of the actual file I want. This may be because when I go to the URL, it doesn't automatically download the file; rather, I am asked to save the file to a certain location (since I don't know the path name of the uploaded file on the site). Is there any way to alter this code to accommodate this, or will I have

Set proxy through windows command line including login parameters

那年仲夏 提交于 2019-12-03 03:15:36
问题 I want to set a proxy throught the command line, first thing I found out is that you have to run command line with administrator rights - then the basic proxy set would be: netsh winhttp set proxy SERVER:PORT This works nice, but I also want to add a login. As you can see I've tried using netsh->winhttp, however manual does not say anything about the login part so I just tried: netsh winhttp set proxy user:password@SERVER:PORT This unfortunately does not work. Is it even possible to achieve

Set proxy through windows command line including login parameters

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 17:13:24
I want to set a proxy throught the command line, first thing I found out is that you have to run command line with administrator rights - then the basic proxy set would be: netsh winhttp set proxy SERVER:PORT This works nice, but I also want to add a login. As you can see I've tried using netsh->winhttp, however manual does not say anything about the login part so I just tried: netsh winhttp set proxy user:password@SERVER:PORT This unfortunately does not work. Is it even possible to achieve something like this in netsh->winhttp? If so, how? If not => what windows commands should I follow?

WinHttp TLS connection in classic asp

核能气质少年 提交于 2019-12-02 13:29:15
I'm trying to send payment data to SagePay and, as they are turning off SSL, it needs to be sent using TLS. The code I have is as follows: set httpRequest = Server.CreateObject("WinHttp.WinHttprequest.5.1") httpRequest.Open "POST", CStr(strPurchaseURL), false httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" httpRequest.send strPost strResponse = httpRequest.responseText I've been told that adding an option lets you set the protocol used but the only one I've found is: httpRequest.option(9) = 2720 which allows for TLS and SSL but it can only be TLS, does anyone

WScript.CreateObject crashes Windows Scripting Host when event handler prefix is specified for WinHTTPRequest

假装没事ソ 提交于 2019-12-01 13:40:49
According to the MSDN documentation WinHTTPRequest has four event handlers which should be accessible by specifying an event handler prefix. Unfortunately, doing so causes Windows Scripting Host to crash. The following code crashes Windows Scripting Host: Set oHTTP = WScript.CreateObject( "WinHttp.WinHttpRequest.5.1", "oHTTP_" ) This code works just fine: Set oHTTP = WScript.CreateObject( "WinHttp.WinHttpRequest.5.1" ) Any thoughts as to why? It's not part of the specification in any way. Wishful programming rarely works. Creates and returns a reference to an Automation object. CreateObject

Save a file downloaded via WinHTTP to disk, using Delphi XE

拥有回忆 提交于 2019-11-30 15:44:10
An answer to this question showed how easy it is to use WinHTTP via Type Library imports in delphi. I imported the type library for WinHTTP, and then tried to write a File Download helper function using that api. Here's how far I got: I can't seem to figure out how to save the IWinHttpRequest.ResponseStream (declared as OleVariant in the TLB file) as Stream, to disk. // IWinHttpRequest is defined by importing type library of WinHTTP. // Microsoft WinHTTP Services, version 5.1 (Version 5.1) C:\Windows\system32\winhttp.dll function Download(const url, filename: String): Boolean; var http: