Using Win32 functions in Visual FoxPro Image Gallery
HTTP Functions (WinHTTP)
WinHttpAddRequestHeaders
WinHttpCloseHandle
WinHttpConnect
WinHttpCrackUrl
WinHttpOpen
WinHttpOpenRequest
WinHttpQueryDataAvailable
WinHttpQueryHeaders
WinHttpReadData
WinHttpReceiveResponse
WinHttpSendRequest
WinHttpSetCredentials
Code examples:
Custom HttpRequest class (WinHTTP)
Custom HttpRequest class (WinHTTP)

User rating: 8/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
Use this class to send HTTP POST, HTTP GET and other HTTP requests. Use the following code to test it:

SET MEMOWIDTH TO 120
#DEFINE ccUrl "http://www.news2news.com/vfp/?example=397"

oHttp = CreateObject("WinHttpRequest")
WITH oHttp
        IF Not .Open("GET", ccUrl)
                ? "Error:", .ErrorCode, .ErrorMsg
        ELSE
                IF Not .Send()
                        ? "Error:", .ErrorCode, .ErrorMsg
                ELSE
                        ? .Status
                        ? .StatusText
                        ? .GetAllResponseHeaders()
                        ? .GetResponseHeader("connection:")
                        ? "Response length:", .ResponseLen
                        SET SAFETY OFF
                        StrToFile(.ResponseText, "tmp.txt")
                        SET SAFETY ON
                        MODI FILE tmp.txt NOWAIT
                ENDIF
        ENDIF
ENDWITH

There is a similar class built on WinINet functions: Custom HttpRequest class (WinINet).
 
  Members area. Log in to view this example.
 
  User name:
  Password:
 
 
  Forgot your password?
 
  Sign up for
the Membership
 
 


User rating: 8/10 (1 votes)
Rate this code sample:
  • ~
12922 bytes  
Created: 2003-04-07 19:20:07  
Modified: 2011-12-10 09:20:22  
Visits in 7 days: 169  
Listed functions:
GetLastError
GlobalAlloc
GlobalFree
GlobalSize
WinHttpAddRequestHeaders
WinHttpCloseHandle
WinHttpConnect
WinHttpCrackUrl
WinHttpOpen
WinHttpOpenRequest
WinHttpQueryDataAvailable
WinHttpQueryHeaders
WinHttpReadData
WinHttpReceiveResponse
WinHttpSendRequest
WinHttpSetCredentials
Printer friendly API declarations
My comment:
Nov. 26, 2003: code completely rewritten.

Take a look at About WinHTTP page on MSDN.

* * *
Dec.26, 2006: For C++ part, install WinHttp 5.1 SDK. The most straightforward way of doing that is downloading 400Mb of Windowsฎ Server 2003 R2 Platform SDK.

#kwd: sln_http.
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
Jacek Cenzartowicz | 2006-10-05 15:31:31
Hello. There is some problem with CrackUrl function from WinHttpRequest class. After HttpCrackUrl, .host property contain in unicode, some extra trash data at end of the string. The .host property is not null terminated.
When class is used from Command Window (DO example397.prg) it's running fine.
But if you call example397.prg form Click method of CommandButton, you will get corrupted .host very often.
I wrote my own CrackUrl, and now this class is working fine.
A.M. | 2006-10-09 13:08:32
Jacek, thanks!

I have added changes to the function. When parsing the return of WinHttpCrackUrl() the Length members of the URL_COMPONENTS structure are used instead of double CHR(0).

Copyright ฉ 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (50.17.109.248)
3 sec.Example: 'Playing WAV sounds simultaneously'
3.09 hrs.Example: 'Storing the environment strings in cursor'
7.17 hrs.Example: 'Obtaining some properties for the Windows desktop using the GetWindowPlacement function'
 Function: 'GetKeyNameText'
Function group: 'Keyboard Input'
7.31 hrs.Function: 'WNetGetConnection'
 Function: 'SetClipboardViewer'
8.11 hrs.Example: 'An alternative way of setting Form.Closable to False'
13.4 hrs.Function: 'GetDoubleClickTime'
Function group: 'Mouse Input'
Google
Advertise here!