Using Win32 functions in Visual FoxPro Image Gallery
Internet Functions (WinInet)
..msdn
CreateMD5SSOHash
DeleteUrlCacheEntry
DetectAutoProxyUrl
FindCloseUrlCache
FindFirstUrlCacheEntry
FindFirstUrlCacheGroup
FindNextUrlCacheEntry
FindNextUrlCacheGroup
FtpCommand
FtpCreateDirectory
FtpDeleteFile
FtpFindFirstFile
FtpGetCurrentDirectory
FtpGetFile
FtpGetFileSize
FtpOpenFile
FtpPutFile
FtpRemoveDirectory
FtpRenameFile
FtpSetCurrentDirectory
GetUrlCacheEntryInfo
HttpOpenRequest
HttpQueryInfo
HttpSendRequest
InternetAttemptConnect
InternetAutodial
InternetAutodialHangup
InternetCanonicalizeUrl
InternetCheckConnection
InternetCloseHandle
InternetConnect
InternetCrackUrl
InternetDial
InternetFindNextFile
InternetGetConnectedState
InternetGetConnectedStateEx
InternetGetCookie
InternetGetLastResponseInfo
InternetGoOnline
InternetOpen
InternetOpenUrl
InternetQueryDataAvailable
InternetQueryOption
InternetReadFile
InternetSetCookie
InternetSetFilePointer
InternetTimeFromSystemTime
InternetTimeToSystemTime
InternetWriteFile
Code examples:
Custom HttpRequest class (WinINet)
Custom HttpRequest class (WinINet)

User rating: 0/10 (0 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:
This class is used for sending "GET" and "POST" HTTP requests. Use the following code to test it:

LOCAL oHttp
oHttp = CreateObject("THttpRequest")
WITH oHttp
        .Open("GET", "http://msdn.microsoft.com/vfoxpro/")
        .Send()

        ? .Status, .StatusText
        ? "Response length:", .ResponseLen
        ? .GetAllResponseHeaders()
*        ? .GetResponseHeader("content-type")

        STRTOFILE(.ResponseText, "response.txt")
        MODI FILE response.txt NOWAIT
ENDWITH

See also:
  • Custom WinHTTP HttpRequest class (WinHTTP)
  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    7310 bytes  
    Created: 2001-11-02 18:25:07  
    Modified: 2011-12-10 09:20:22  
    Visits in 7 days: 154  
    Listed functions:
    GetLastError
    HttpOpenRequest
    HttpQueryInfo
    HttpSendRequest
    InternetCloseHandle
    InternetConnect
    InternetOpen
    InternetQueryDataAvailable
    InternetReadFile
    Printer friendly API declarations
    My comment:
    Nov. 2, 2003: code completely rewritten.

    List of HTTP Status Codes on MSDN.

    Recommended reading:
    Post FoxPro Data to Your Web Server with WinInet written by Rick Strahl and published in April 1998 issue of FoxPro Advisor.

    * * *
    Here is a simple example of using this class to exchange information between VFP application and ASP.Net page. Two pieces of code, VFP and .Net, are required. VFP part posts HTTP Request stuffed with some data. C# part extracts data from the request, processes it and sends back a response.

    Create ASP.Net Web application and call it SendRequest. Add new web form and call it ExchangeData.aspx. Both names are optional, though the complete name of the page (URL) must be provided to the VFP part.

    Remove all HTML code from the web form. It is not going to be used anyway; moreover it may affect sending HTTP response headers. Open the code part (C#) and add the following method to ExchangeData class.

    private void ProcessRequest()
    {
            //read HTTP Request header
            string sender = Request.Headers["Request_Sender"];

            //convert body of HTTP Request to array of bytes...
            System.IO.Stream s = Request.InputStream;
            byte[] buffer = new byte[(int) s.Length];
            s.Read(buffer, 0, (int) s.Length);

            //...and then to string
            ASCIIEncoding enc = new ASCIIEncoding();
            string b = enc.GetString(buffer);

            //send back data as HTTP Response header
            Response.AddHeader("Request_Confirmation",
                    "Dear " + sender +
                    "! Your request has been received at " +
                    DateTime.Now.ToString() + ".");

            //send back data as HTTP Response body
            Response.Write("Request received: " + b);
            Response.End();
    }

    Call ProcessRequest from Page_Load method of the web form. Compile .Net SendRequest project.

    Then create a VFP part for sending requests and obtaining responses from ASP.Net page. As I said, this part must include URL for the webpage. The local server is used for simplicity.

    #DEFINE DESTINATION_URL;
            "http://localhost/sendrequest/exchangedata.aspx"
    SET PROCEDURE TO HttpRequest ADDITIVE

    LOCAL oHttp As THttpRequest
    oHttp = CREATEOBJECT("THttpRequest")

    oHttp.Open("POST", DESTINATION_URL)
    oHttp.SetRequestHeader("Request_Sender", SYS(0))

    WAIT WINDOW NOWAIT "Sending HTTP Request..."
    oHttp.Send(FILETOSTR("config.fpw")) && body
    WAIT CLEAR

    WITH oHttp
            ? .status && returns "200"
            ? .GetResponseHeader("Request_Confirmation")
            ? .ResponseText
    ENDWITH

    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:
    There are no notes on this subject.


    Copyright 2001-2017 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.6.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.156.92.243)
    8 sec.Function: 'QueryDosDevice'
    Function group: 'File Management'
    17 sec.Function: 'NetWkstaTransportEnum'
    Function group: 'Network Management'
    25 sec.Example: 'Opening access to the Microsoft Internet functions for the application'
    34 sec.Examples
    43 sec.Function: 'sndPlaySound'
    Function group: 'Windows Multimedia'
    55 sec.Function: 'UnhookWindowsHookEx'
    Function group: 'Hook'
    1.07 min.Function: 'ExitProcess'
    Function group: 'Process and Thread'
    1.23 min.
    1.58 min.Function: 'CeGetSpecialFolderPath'
    Function group: 'Remote Application Programming (RAPI)'
    Google
    Advertise here!