FoxPro Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
Socket
Spider
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Amazon S3
DKIM / DomainKey
NTLM
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA
FileAccess
Bzip2
LZW

 

Non-Chilkat Links
Text and String Handling

(Visual FoxPro) Adding Cookies to an HTTP Request

Demonstrates how to add one or more cookies to an HTTP request. For Chilkat HTTP methods that use an HTTP request object, such as SynchronousRequest or PostUrlEncoded, cookies are added by calling the AddHeader method on the request object. For Chilkat HTTP methods that do not use an HTTP request object, such as QuickGetStr, cookies are added by calling AddQuickHeader.

Download Chilkat HTTP ActiveX

LOCAL loHttp
LOCAL lnSuccess
LOCAL loRequest
LOCAL loResponse
LOCAL lcDomain
LOCAL lnPort
LOCAL lnSsl
LOCAL lcHtml

loHttp = CreateObject('Chilkat.Http')

*  Any string unlocks the component for the 1st 30-days.
lnSuccess = loHttp.UnlockComponent("Anything for 30-day trial")
IF (lnSuccess <> 1) THEN
    ? loHttp.LastErrorText
    QUIT
ENDIF

*  The Cookie header field has this format:
*  Cookie: name1=value1 [; name2=value2] ...

*  Build an HTTP POST request:
loRequest = CreateObject('Chilkat.HttpRequest')
loRequest.SetFromUrl("http://www.chilkatsoft.com/echoPost.asp")
loRequest.HttpVerb = "POST"

loRequest.AddParam("param1","value1")
loRequest.AddParam("param2","value2")

*  To add cookies to any HTTP request sent by a Chilkat HTTP method
*  that uses an HTTP request object, add the cookies to the
*  request object by calling AddHeader.

*  Add two cookies:
loRequest.AddHeader("Cookie",[user="mary"; city="Chicago"])

*  Send the HTTP POST.
*  (The cookies are sent as part of the HTTP header.)

lcDomain = "www.chilkatsoft.com"

lnPort = 80

lnSsl = 0
loResponse = loHttp.SynchronousRequest(lcDomain,lnPort,lnSsl,loRequest)
IF (loResponse = NULL ) THEN
    ? loHttp.LastErrorText
    QUIT
ENDIF

*  Display the HTML body of the response.
IF (loResponse.StatusCode = 200) THEN
    *  Show the last HTTP request header sent, which should include
    *  our cookies...
    ? loHttp.LastHeader
ELSE
    ? "HTTP Response Status = " + loResponse.StatusCode
ENDIF

RELEASE loResponse

? "---------------------"

*  Some Chilkat HTTP methods do not use an HTTP request object.
*  For these methods, such as for QuickGetStr, cookies (or any HTTP request header)
*  are added by calling AddQuickHeader.
loHttp.AddQuickHeader("Cookie",[user="mary"; city="Chicago"])

lcHtml = loHttp.QuickGetStr("http://www.w3.org/")
IF (lcHtml = NULL ) THEN
    ? loHttp.LastErrorText
ELSE
    *  Show the last HTTP request header sent, which should include
    *  our cookies...
    ? loHttp.LastHeader
ENDIF

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · ASP Mail Component · XML Parser