Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  

CURL.SetOptionConnectOnly

Connect only.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
CURL 7.2 Yes Yes Yes Yes Yes

MBS( "CURL.SetOptionConnectOnly" )

Parameters

none

Result

Returns OK or error.

Description

Connect only.
A 1 tells the library to perform any required proxy authentication and connection setup, but no data transfer.

Use this option to tell CURL to connect only and than send/receive data with your own protocol.
See CURL.SendData, CURL.SendText, CURL.ReceiveText and CURL.ReceiveData.

Examples

Download website and handle protocol ourself:

#Start new session
Set Variable [$curl; Value:MBS("CURL.New")]
#Set URL to load (HTTP, HTTPS, FTP, FTPS, SFTP, etc.)
Set Variable [$result; Value:MBS("CURL.SetOptionConnectOnly"; $curl; 1)]
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; CURL Low Level Sockets::URL)]
Set Variable [$request; Value:"GET / HTTP/1.1¶Host: www.monkeybreadsoftware.de¶¶" // must end with two empty lines ]
Set Variable [$request2; Value:MBS( "Text.ReplaceNewline"; $request; 3)]
#RUN now
Set Field [CURL Low Level Sockets::Connect Result; MBS("CURL.Perform"; $curl)]
#Check result
Set Field [CURL Low Level Sockets::Data Received; MBS("CURL.GetResultAsText"; $curl; "UTF8")]
Set Field [CURL Low Level Sockets::Debug Messages; MBS("CURL.GetDebugAsText"; $curl)]
If [CURL Low Level Sockets::Connect Result = "OK"]
    Set Variable [$r; Value:MBS( "CURL.SendText"; $curl; $request2; "UTF-8")]
    Set Field [CURL Low Level Sockets::Data Sent; $request]
    Set Variable [$received; Value:""]
    Loop
        Pause/Resume Script [Duration (seconds): ,1]
        Set Variable [$r; Value:MBS( "CURL.ReceiveText"; $curl; 100000; "UTF-8")]
        Set Variable [$errorCode; Value:MBS( "CURL.ErrorCode"; $curl)]
        If [GetAsNumber ( $errorCode ) = 81]
            #wait
        Else If [GetAsNumber ( $errorCode ) = 0]
            #got some data
            Set Variable [$received; Value:$received & $r]
            Exit Loop If [$r = ""]
        Else
            #error
            Exit Loop If [1]
        End If
    End Loop
    Set Variable [$received2; Value:MBS( "Text.ReplaceNewline"; $received; 1)]
    Set Field [CURL Low Level Sockets::Debug Messages; MBS("CURL.GetDebugAsText"; $curl)]
    Set Field [CURL Low Level Sockets::Data Received; $received2]
End If
#Cleanup
Set Variable [$result; Value:MBS("CURL.Cleanup"; $curl)]

See also

Example Databases


CURL.SetOptionCertInfo   -   CURL.SetOptionConnectTimeoutMS

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins