winhttp

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

风格不统一 提交于 2019-11-29 23:15:48
问题 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:

Not understanding why WinHTTP does NOT authenticate certain HTTPS resource

孤街醉人 提交于 2019-11-29 12:44:46
I'd be extremely grateful for any kind of help that may help me resolving the problem. From Excel VBA code I need to download & parse CSV file from HTTPS site https://redmine.itransition.com/ . I try to use WinHTTP to get the file. However, I can't understand why authentication does not work. Here is the piece of related code: TargetURL = "https://redmine.itransition.com/projects/pmct/time_entries.csv" Set HTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1") HTTPReq.Option(4) = 13056 ' WinHttpRequestOption_SslErrorIgnoreFlags 13056: ignore all err, 0: accept no err HTTPReq.Open "GET",

WinHTTP VBA subsequent request cannot use the previous login credentials?

a 夏天 提交于 2019-11-29 05:11:05
I'm using WinHTTP in Access 2007 VBA to fetch some list of items requiring a cookie login credential account . First I login through https://www.example.com/login.php with this: Dim strCookie As String, strResponse As String, _ strUrl As String ' Dim xobj As Object ' Set xobj = New WinHttp.WinHttpRequest ' strUrl = "https://www.example.com/login.php" xobj.Open "POST", strUrl, False xobj.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" xobj.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" xobj.Send "username=johndoe2&password=mypassword" '

How do I prevent ServerXMLHTTP from automatically following redirects (HTTP 303 See Other responses)?

旧城冷巷雨未停 提交于 2019-11-28 11:35:48
I am using ServerXMLHTTP to perform an HTTP POST. The response returned is a redirect (specifically 303 See Other). ServerXMLHTTP is automatically following this redirect but this is causing an authentication failure as is not propagating the Authorization header of the original request. Is there a way I can prevent the automatic redirection (or alternatively ensure that the Authorization header is resent)? ServerXMLHTTP does not support interception of redirects (see Microsoft Knowledge Base Article 308607 ). However WinHTTP can be used in its place and this does contain a configurable

WinHTTP.WinHTTPRequest.5.1 does not work with PayPal sandbox after TLS 1.2

爱⌒轻易说出口 提交于 2019-11-28 08:50:47
PayPal sandbox just recently restricted to TLS 1.2 connection. This makes our site stop working with PayPal sandbox although it stills work with the production PayPal. In the future the production PayPal will have the same restriction. We're using classic ASP and Microsoft WinHTTP.WinHTTPRequest.5.1 component for communication with PayPal. Here's the code below. objHttp.StatusText returns "Bad Request". We're on Windows Server 2008 R2. I tried to use MSXML2.ServerXMLHTTP.6.0 instead, but it only works on my Windows 8.1 development machine, not on our Windows Server 2008 R2. Although MSXML2

How to parse line by line WinHTTP response: UTF-8 encoded CSV?

别来无恙 提交于 2019-11-28 01:36:10
As the next step for my happily solved problem ( Not understanding why WinHTTP does NOT authenticate certain HTTPS resource ) I need to prettily parse obtained CSV. At the moment I use the following solution: If HTTPReq.Status = 200 Then If FSO.FileExists(CSV_Path) = True Then FSO.DeleteFile (CSV_Path) Set FileStream = CreateObject("ADODB.Stream") FileStream.Open FileStream.Type = 1 FileStream.Write HTTPReq.responseBody FileStream.SaveToFile (CSV_Path) FileStream.Close ActiveWorkbook.Connections("Redmine Timelog").Refresh ActiveSheet.PivotTables("PivotTable_RM").PivotCache.Refresh End If That

WinHTTP VBA subsequent request cannot use the previous login credentials?

荒凉一梦 提交于 2019-11-27 19:03:42
问题 I'm using WinHTTP in Access 2007 VBA to fetch some list of items requiring a cookie login credential account . First I login through https://www.example.com/login.php with this: Dim strCookie As String, strResponse As String, _ strUrl As String ' Dim xobj As Object ' Set xobj = New WinHttp.WinHttpRequest ' strUrl = "https://www.example.com/login.php" xobj.Open "POST", strUrl, False xobj.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" xobj.SetRequestHeader

WinHttp Delphi wrapper

余生颓废 提交于 2019-11-27 15:03:08
问题 Please advise if there is a WinHTTP wrapper in Delphi XE In order of preference: a Delphi out of the box unit a third party open source pas file with ported entry routines a xxx_TLB.pas wrapper Solution: Since comments do not allow formatted code I am pasting the solution in the questions: const winhttpdll = 'winhttp.dll'; WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0; WINHTTP_FLAG_REFRESH = $00000100; WINHTTP_FLAG_SECURE = $00800000; WINHTTP_ADDREQ_FLAG_COALESCE = $40000000; WINHTTP_QUERY_FLAG

differences between Msxml2.ServerXMLHTTP and WinHttp.WinHttpRequest?

白昼怎懂夜的黑 提交于 2019-11-27 14:45:00
问题 just when I finally understood the difference between Msxml2.XMLHTTP and Msxml2.ServerXMLHTTP http://support.microsoft.com/kb/290761 XMLHTTP is designed for client applications and relies on URLMon, which is built upon Microsoft Win32 Internet (WinInet). ServerXMLHTTP is designed for server applications and relies on a new HTTP client stack, WinHTTP. ServerXMLHTTP offers reliability and security and is server-safe. For more information, see the MSXML Software Development Kit (SDK)

VBA WinHTTP to download file from password proteced https website

爷,独闯天下 提交于 2019-11-27 09:09:49
I'm trying to save a file from https password protected site using WinHTTP. Here's the code: Sub SaveFileFromURL() Dim FileNum As Long Dim FileData() As Byte Dim WHTTP As Object fileUrl = "https://www.website.com/dir1/dir2/file.xls" filePath = "C:\myfile.xls" myuser = "username" mypass = "password" Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5.1") WHTTP.Open "GET", fileUrl, False WHTTP.SetCredentials myuser, mypass, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER WHTTP.Send FileData = WHTTP.ResponseBody Set WHTTP = Nothing FileNum = FreeFile Open filePath For Binary Access Write As #FileNum Put