winhttprequest

winHTTP GET request C++

喜夏-厌秋 提交于 2019-12-06 13:31:59
问题 I'll get right to the point. This is what a browser request looks like GET /index.html HTTP/1.1 This is what winHTTP does GET http://site.com/index.html HTTP/1.1 Is there any I can get the winHTTP request to be the same format as the regular one? I'm using VC++ 2008 if it makes any difference 回答1: Your code should look like this: // Specify an HTTP server. if (hSession) hConnect = WinHttpConnect( hSession, L"www.example.com", INTERNET_DEFAULT_HTTP_PORT, 0); // Create an HTTP request handle.

WinHttp doesn't work when hostname doesn't contains www. (error 12029)

五迷三道 提交于 2019-12-06 05:06:42
I am testing this winhttp example from http://msdn.microsoft.com/en-us/library/aa384270%28v=vs.85%29.aspx DWORD dwSize = 0; DWORD dwDownloaded = 0; LPSTR pszOutBuffer; BOOL bResults = FALSE; HINTERNET hSession = NULL, hConnect = NULL, hRequest = NULL; // Use WinHttpOpen to obtain a session handle. hSession = WinHttpOpen( L"WinHTTP Example/1.0", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0 ); // Specify an HTTP server. if( hSession ) hConnect = WinHttpConnect( hSession, L"www.microsoft.com", INTERNET_DEFAULT_HTTPS_PORT, 0 ); // Create an HTTP request

Post Method + WinHttpRequest + multipart/form-data

北战南征 提交于 2019-12-06 03:05:00
I'm stumped why this doesn't work can't seem to find any problems. Here is the code. Public Const MULTIPART_BOUNDARY = "speed" Function getBalance() As String Dim sEntityBody As String Dim postBody() As Byte Dim username As String Dim password As String username = CStr(frmMain.txtUser.text) password = CStr(frmMain.txtPass.text) sEntityBody = "--" & MULTIPART_BOUNDARY & vbCrLf sEntityBody = sEntityBody & "Content-Disposition: form-data; name=""function""" & vbCrLf & vbCrLf & "balance" & vbCrLf sEntityBody = sEntityBody & "--" & MULTIPART_BOUNDARY & vbCrLf sEntityBody = sEntityBody & "Content

winHTTP GET request C++

主宰稳场 提交于 2019-12-04 18:21:37
I'll get right to the point. This is what a browser request looks like GET /index.html HTTP/1.1 This is what winHTTP does GET http://site.com/index.html HTTP/1.1 Is there any I can get the winHTTP request to be the same format as the regular one? I'm using VC++ 2008 if it makes any difference Your code should look like this: // Specify an HTTP server. if (hSession) hConnect = WinHttpConnect( hSession, L"www.example.com", INTERNET_DEFAULT_HTTP_PORT, 0); // Create an HTTP request handle. if (hConnect) hRequest = WinHttpOpenRequest( hConnect, L"GET", L"/path/resource.html", NULL, WINHTTP_NO

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

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

http response text fetching incomplete html

怎甘沉沦 提交于 2019-12-02 02:33:11
I have a code (given below) in excel vba that fetches web page source html. The code is working fine but the html that it fetches is incomplete. When the line webpageSource = oHttp.ResponseText is executed, the variable webpageSource contains "DOCTYPE html PUBLIC ....... etc etc till the end /html" and that is how it should be. Everything is correct till here. But the next line debug.print webpageSource prints only half the html from "(adsbygoogle = window.adsbygoogle || []).push({}); ...... etc etc till the end /html" Why is that so? I want to find some strings from the returned response text

Getting an IStream from an OleVariant

寵の児 提交于 2019-12-01 21:56:44
I am using Delphi along with WinHTTP to do an HTTP request to download some files from the internet, and I can do the request but I don't know how to get the IStream from the OleVariant that is returned from ResponseStream . I have spent a lot of time googling but I can't figure out how to do it. Here is what I have tried: var req: IWinHTTPRequest; instream: IStream; begin req := CoWinHTTPRequest.Create; req.Open('GET', 'http://google.com', false); req.Send(''); if req.Status <> 200 then begin ShowMessage('failure'#10 + req.StatusText); FreeAndNil(req); Application.Terminate; end; instream :=

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

How to do logins using the WinHttpRequest COM?

老子叫甜甜 提交于 2019-11-29 07:59:32
You can see lots of people automating things on websites using mouseclick and keystroke simulation on browser windows or using the IE COM, but for some applications you don't want your application to take hundrets of megabytes of RAM and use loads of CPU power to render the website etc. So the question is: How to do logins to websites / webservices using AutoHotkey without a browser but using the WinHttpRequest COM? I already posted this on the AHK forums, but I think the information is useful enough to get archived on Stackoverflow as well. :) Tools & getting started First of all, if you want