HttpSock
Base of LibHTTP this implements the main network methods for connecting to a
webserver and retreiving data from it
Features:
- GET/POST support
- Supports transparent redirecting
- Basic Authentication support
- Header management
- Cookie management
- Support for HTTP Proxy
Constants
- BUFFERSIZE = 2048
- the output buffer size
- VERSION = 105
- LibHTTP version number
Properties
- bool bFollowRedirect
- when set to false it won't follow redirects
- bool bProcCookies
- Process incoming cookies, defaults to false
- bool bSendCookies
- Send cookie data, defaults to true
- bool bUseProxy
- Use a proxy server
- HTTPCookies Cookies
- the cookie data instance
- string CRLF
- constant CR LF
- HTTPState curState
- The current state of the socket
- string HTTPVER
- The HTTP version to use, 1.0 adviced
- int iLocalPort
- the local port, leave zero to use a random port (adviced)
- int iMaxRedir
- Maximum redirections to follow
- int iPort
- the remote port
- int iProxyPort
- The proxy port
- int iVerbose
- log verbosity
- int LastStatus
- The last returned HTTP status code
- array<string> RequestData
- the request data
- array<string> RequestHeaders
- the request headers
- string RequestLocation
- the requested location
- string RequestMethod
- the request method
- array<string> ReturnData
- the return data
- array<string> ReturnHeaders
- the return headers
- string sAuthPassword
- the username and password to use when authentication is required
- string sAuthUsername
- the username and password to use when authentication is required
- string sHostname
- the remote host
- string sProxyHost
- The hostname of the proxy
- int TZoffset
- Timezone Offset, dynamically calculated from the server's time
Enums
HTTPState
- HTTPState_Resolving
- HTTPState_Connecting
- HTTPState_ReceivingData
- HTTPState_Closed
Delegates
- OnComplete( )
- will be called when the operation was complete
- OnError( string ErrorMessage , optional string Param1 , optional string Param2 )
- will be called in case of an internal error
- bool OnResolved( )
- will be called when the host name is resolved
return true to continue, or false to abort - OnReturnCode( int ReturnCode , string ReturnMessage , string HttpVer )
- will be called when the return code has been received;
Functions
- bool Abort( )
- Abort the current request, if possible
- AddHeader( string hname , string value , optional bool bNoReplace )
- Add a header, case insensitive
set bNoReplace to false to not overwrite the old header - int DataSize( array<string> data )
- string genBasicAuthorization( string Username , string Password )
- Generated a basic authentication
- string GetRequestHeader( string hname , optional string def )
- Returns the value of the requested header, or default if not found
- string GetReturnHeader( string hname , optional string def )
- Returns the value of the returned header, or default if not found
- bool HttpRequest( string location , optional string Method , optional HTTPCookies CookieData )
- Start the HTTP request
location can be a fully qualified url, or just the location on the configured server
Method defaults to GET - bool IsSupportedMethod( )
- Returns true when the request method is supported
- Logf( coerce string message , optional int level , optional coerce string Param1 , optional coerce string Param2 )
- int now( )
- Returns the current timestamp
- ParseRequestUrl( string location , string Method )
- Parses the fully qualified URL
- ProcInput( string inline )
- Process the input
- bool RemoveHeader( string hname )
- Remove a header, case insensitive
Returns true when the header is deleted - SendData( string data , optional bool bFlush )
- Send data buffered
if bFlush it will flush all remaining data (should be used for the last call) - string UserAgent( )
- Returns the useragent string we use
Events
- Closed( )
- Opened( )
- ReceivedText( string Line )
- Resolved( IpAddr Addr )
- hostname has been resolved
- ResolveFailed( )