Difference between revisions of "THttpCli"

From Overbyte
Jump to navigation Jump to search
 
(10 intermediate revisions by 4 users not shown)
Line 6: Line 6:
 
*'''inheritance''' THttpCli - TComponent
 
*'''inheritance''' THttpCli - TComponent
  
THttpCli component is implementing the client side HTTP protocol described in RFC [http://rfc.net/rfc1945.html 1945] and RFC [http://rfc.net/rfc2068.html 2068]. HTTP protocol is the standard protocol for browsing the World Wide Web.
+
THttpCli component is implementing the client side HTTP protocol described in RFC [http://rfc.net/rfc1945.html 1945] and RFC [http://rfc.net/rfc2068.html 2068]. HTTP protocol is the standard protocol for browsing the World Wide Web. If you need an encrypted connection, use the SslHTTPCli component instead.
  
 
== Properties ==
 
== Properties ==
Line 19: Line 19:
 
| valign="top" width="150" | [[THttpCli.Agent | Agent]] |||| User agent sent to server.
 
| valign="top" width="150" | [[THttpCli.Agent | Agent]] |||| User agent sent to server.
 
|-
 
|-
| valign="top" width="150" | [[THttpCli.AuthorizationRequest | AuthorizationRequest]] ||||
+
| valign="top" width="150" | [[THttpCli.AuthorizationRequest | AuthorizationRequest]] |||| List of authentication methods.
 
|-
 
|-
 
| valign="top" width="150" | [[THttpCli.Connection | Connection]] |||| Connection type for keep-alive.
 
| valign="top" width="150" | [[THttpCli.Connection | Connection]] |||| Connection type for keep-alive.
Line 35: Line 35:
 
| valign="top" width="150" | [[THttpCli.Cookie | Cookie]] |||| Cookies to be sent.
 
| valign="top" width="150" | [[THttpCli.Cookie | Cookie]] |||| Cookies to be sent.
 
|-
 
|-
| valign="top" width="150" | [[TWSocket | CtrlSocket]] |||| Underlaying {{CtrlSocket}}
+
| valign="top" width="150" | [[TWSocket | CtrlSocket]] |||| {{CtrlSocket}}
 
|-
 
|-
 
| valign="top" width="150" | [[THttpCli.DnsResult | DnsResult]] |||| Result of DNS request.
 
| valign="top" width="150" | [[THttpCli.DnsResult | DnsResult]] |||| Result of DNS request.
Line 49: Line 49:
 
| valign="top" width="150" | [[THttpCli.LastResponse | LastResponse]] |||| Last response from server.
 
| valign="top" width="150" | [[THttpCli.LastResponse | LastResponse]] |||| Last response from server.
 
|-
 
|-
| valign="top" width="150" | [[THttpCli.LocalAddr | LocalAddr]] |||| Local address to which underlaying socket is bound.
+
| valign="top" width="150" | [[THttpCli.LocalAddr | LocalAddr]] |||| Local address to which underlying socket is bound.
 
|-
 
|-
 
| valign="top" width="150" | [[THttpCli.Location | Location]] |||| Where the relocation will take place.
 
| valign="top" width="150" | [[THttpCli.Location | Location]] |||| Where the relocation will take place.
Line 63: Line 63:
 
| valign="top" width="150" | [[THttpCli.Protocol | Protocol]] |||| Protocol extracted from the URL.
 
| valign="top" width="150" | [[THttpCli.Protocol | Protocol]] |||| Protocol extracted from the URL.
 
|-
 
|-
| valign="top" width="150" | [[THttpCli.Proxy | Proxy]] |||| Proxy to traverse to before connecting.
+
| valign="top" width="150" | [[THttpCli.Proxy | Proxy]] |||| Proxy to traverse to before connecting. The IP address or hostname of the proxy server.
 
|-
 
|-
| valign="top" width="150" | [[THttpCli.ProxyConnection | ProxyConnection]] |||| Type of proxy connection.
+
| valign="top" width="150" | [[THttpCli.ProxyConnection | ProxyConnection]] |||| Type of proxy connection. "Keep-Alive" or blank.
 
|-
 
|-
 
| valign="top" width="150" | [[THttpCli.ProxyPort | ProxyPort]] |||| Port to be used to connect to proxy.
 
| valign="top" width="150" | [[THttpCli.ProxyPort | ProxyPort]] |||| Port to be used to connect to proxy.
 +
|-
 +
| valign="top" width="150" | [[THttpCli.ProxyURL | ProxyURL]] |||| Combines four proxy properties as a URL for simplicity, i.e. http://[user[:password]@]host:port. Set ProxyAuth if that is required.
 
|-
 
|-
 
| valign="top" width="150" | [[THttpCli.RcvdCount | RcvdCount]] |||| Bytes received.
 
| valign="top" width="150" | [[THttpCli.RcvdCount | RcvdCount]] |||| Bytes received.
Line 73: Line 75:
 
| valign="top" width="150" | [[THttpCli.RcvdHeader | RcvdHeader]] |||| Received header.
 
| valign="top" width="150" | [[THttpCli.RcvdHeader | RcvdHeader]] |||| Received header.
 
|-
 
|-
| valign="top" width="150" | [[THttpCli.RcvdStream | RcvdStream]] |||| Stream to write received document.
+
| valign="top" width="150" | [[THttpCli.RcvdStream | RcvdStream]] |||| Stream to receive a document.
 
|-
 
|-
 
| valign="top" width="150" | [[THttpCli.ReasonPhrase | ReasonPhrase]] |||| Status returned by server.
 
| valign="top" width="150" | [[THttpCli.ReasonPhrase | ReasonPhrase]] |||| Status returned by server.
 
|-
 
|-
| valign="top" width="150" | [[THttpCli.Reference | Reference]] |||| To send the referer to the server.  
+
| valign="top" width="150" | [[THttpCli.Reference | Reference]] |||| To send the referrer to the server.  
 
|-
 
|-
 
| valign="top" width="150" | [[THttpCli.RequestVer | RequestVer]] |||| HTTP version to be used in the request.
 
| valign="top" width="150" | [[THttpCli.RequestVer | RequestVer]] |||| HTTP version to be used in the request.
Line 103: Line 105:
 
| valign="top" width="150" | [[THttpCli.StatusCode | StatusCode]] |||| Server status code.
 
| valign="top" width="150" | [[THttpCli.StatusCode | StatusCode]] |||| Server status code.
 
|-
 
|-
| valign="top" width="150" | [[THttpCli.TransferEncoding | TransferEncoding]] ||||
+
| valign="top" width="150" | [[THttpCli.TransferEncoding | TransferEncoding]] |||| Received document transfer encoding.
 
|-
 
|-
 
| valign="top" width="150" | [[THttpCli.URL | URL]] |||| Complete URL to act on
 
| valign="top" width="150" | [[THttpCli.URL | URL]] |||| Complete URL to act on
Line 111: Line 113:
  
 
{|
 
{|
| valign="top" width="150" | [[THttpCli.Abort | Abort]] |||| align test
+
| valign="top" width="150" | [[THttpCli.Abort | Abort]] |||| Abort the current operation.
 
|-
 
|-
| [[THttpCli.Close | Close]] ||||
+
| [[THttpCli.Close | Close]] |||| Close the current connection (synchronous).
 
|-
 
|-
| [[THttpCli.CloseAsync | CloseAsync]] ||||
+
| [[THttpCli.CloseAsync | CloseAsync]] |||| Close the current connection (asynchronous).
 
|-
 
|-
| [[THttpCli.Create | Create]] ||||
+
| [[THttpCli.Create | Create]] |||| Create a new component instance.
 
|-
 
|-
| [[THttpCli.Destroy | Destroy]] ||||
+
| [[THttpCli.Destroy | Destroy]] |||| Destroy the current component instance.
 
|-
 
|-
| [[THttpCli.Get | Get]] ||||
+
| [[THttpCli.Get | Get]] |||| Request an URL using GET method (synchronous).
 
|-
 
|-
| [[THttpCli.GetASync | GetASync]] ||||
+
| [[THttpCli.GetASync | GetASync]] |||| Request an URL using GET method (asynchronous).
 
|-
 
|-
| [[THttpCli.Head | Head]] ||||
+
| [[THttpCli.Head | Head]] |||| Request the header for an URL (synchronous).
 
|-
 
|-
| [[THttpCli.HeadASync | HeadASync]] ||||
+
| [[THttpCli.HeadASync | HeadASync]] |||| Request the header for an URL (asynchronous).
 
|-
 
|-
| [[THttpCli.Post | Post]] ||||
+
| [[THttpCli.Post | Post]] |||| Request an URL using the POST method (synchronous).
 
|-
 
|-
| [[THttpCli.PostASync | PostASync]] ||||
+
| [[THttpCli.PostASync | PostASync]] |||| Request an URL using the POST method (asynchronous).
 
|-
 
|-
| [[THttpCli.Put | Put]] ||||
+
| [[THttpCli.Put | Put]] |||| Request an URL using the PUT method (synchronous).
 
|-
 
|-
| [[THttpCli.PutASync | PutASync]] |||| align test
+
| [[THttpCli.PutASync | PutASync]] |||| Request an URL using the PUT method (asynchronous).
 
|}
 
|}
  
Line 141: Line 143:
  
 
{|
 
{|
| valign="top" width="150" | [[THttpCli.OnBeforeHeaderSend | OnBeforeHeaderSend]] |||| align test
+
| valign="top" width="150" | [[THttpCli.OnBeforeHeaderSend | OnBeforeHeaderSend]] |||| Triggered before the header is sent.
|-
 
| [[THttpCli.OnCommand | OnCommand]] ||||
 
|-
 
| [[THttpCli.OnCookie | OnCookie]] ||||
 
 
|-
 
|-
| [[THttpCli.OnDataPush | OnDataPush]] ||||
+
| [[THttpCli.OnCommand | OnCommand]] |||| Triggered for each command sent.
 
|-
 
|-
| [[THttpCli.OnDataPush2 | OnDataPush2]] ||||
+
| [[THttpCli.OnCookie | OnCookie]] |||| Triggered when a cookie has been received.
 
|-
 
|-
| [[THttpCli.OnDocBegin | OnDocBegin]] ||||
+
| [[THttpCli.OnDataPush | OnDataPush]] |||| Received data outside of any request.
 
|-
 
|-
| [[THttpCli.OnDocData | OnDocData]] ||||
+
| [[THttpCli.OnDataPush2 | OnDataPush2]] |||| Received data outside of a header.
 
|-
 
|-
| [[THttpCli.OnDocEnd | OnDocEnd]] ||||
+
| [[THttpCli.OnDocBegin | OnDocBegin]] |||| Triggered when the document part is about to be received.
 
|-
 
|-
| [[THttpCli.OnHeaderBegin | OnHeaderBegin]] ||||
+
| [[THttpCli.OnDocData | OnDocData]] |||| Triggered for each packet of the document part.
 
|-
 
|-
| [[THttpCli.OnHeaderData | OnHeaderData]] ||||
+
| [[THttpCli.OnDocEnd | OnDocEnd]] |||| Triggered when the document is complete.
 
|-
 
|-
| [[THttpCli.OnHeaderEnd | OnHeaderEnd]] ||||
+
| [[THttpCli.OnHeaderBegin | OnHeaderBegin]] |||| Triggered when the first header line is about to be received.
 
|-
 
|-
| [[THttpCli.OnLocationChange | OnLocationChange]] ||||
+
| [[THttpCli.OnHeaderData | OnHeaderData]] |||| Triggered for each received header line.
 
|-
 
|-
| [[THttpCli.OnRequestDone | OnRequestDone]] ||||
+
| [[THttpCli.OnHeaderEnd | OnHeaderEnd]] |||| Triggered when the header has been completely received.
 
|-
 
|-
| [[THttpCli.OnRequestHeaderBegin | OnRequestHeaderBegin]] ||||
+
| [[THttpCli.OnLocationChange | OnLocationChange]] |||| Triggered whenever the server sent a location change.
 
|-
 
|-
| [[THttpCli.OnRequestHeaderEnd | OnRequestHeaderEnd]] ||||
+
| [[THttpCli.OnRequestDone | OnRequestDone]] |||| Triggered when a request is completed.
 
|-
 
|-
| [[THttpCli.OnSendBegin | OnSendBegin]] ||||
+
| [[THttpCli.OnRequestHeaderBegin | OnRequestHeaderBegin]] |||| Triggered when the first header line is about to be sent.
 
|-
 
|-
| [[THttpCli.OnSendData | OnSendData]] ||||
+
| [[THttpCli.OnRequestHeaderEnd | OnRequestHeaderEnd]] |||| Triggered when the last header line has been sent.
 
|-
 
|-
| [[THttpCli.OnSendEnd | OnSendEnd]] ||||
+
| [[THttpCli.OnSendBegin | OnSendBegin]] |||| Triggered before sending document part.
 
|-
 
|-
| [[THttpCli.OnSessionClosed | OnSessionClosed]] ||||
+
| [[THttpCli.OnSendData | OnSendData]] |||| Triggered when sending document part.
 
|-
 
|-
| [[THttpCli.OnSessionConnected | OnSessionConnected]] ||||
+
| [[THttpCli.OnSendEnd | OnSendEnd]] |||| Triggered when document has been sent completely.
 
|-
 
|-
| [[THttpCli.OnSocketError | OnSocketError]] ||||
+
| [[THttpCli.OnSessionClosed | OnSessionClosed]] |||| Triggered when the current connection has been closed.
 
|-
 
|-
| [[THttpCli.OnSocksAuthState | OnSocksAuthState]] ||||
+
| [[THttpCli.OnSessionConnected | OnSessionConnected]] |||| Triggered when the connection has been openend.
 
|-
 
|-
| [[THttpCli.OnSocksConnected | OnSocksConnected]] ||||
+
| [[THttpCli.OnSocketError | OnSocketError]] |||| Triggered when a socket error occured.
 
|-
 
|-
| [[THttpCli.OnSocksError | OnSocksError]] ||||
+
| [[THttpCli.OnSocksConnected | OnSocksConnected]] |||| Triggered when connected to socks server.
 
|-
 
|-
| [[THttpCli.OnStateChange | OnStateChange]] ||||
+
| [[THttpCli.OnSocksError | OnSocksError]] |||| Triggered when a error occurs with the socks server.
 
|-
 
|-
| [[THttpCli.OnTrace | OnTrace]] ||||
+
| [[THttpCli.OnStateChange | OnStateChange]] |||| Triggered when component state change.
 
|}
 
|}
  

Latest revision as of 15:45, 5 December 2019

Main page -> ICS components reference -> THttpCli

Overview

  • unit HttpProt.pas
  • inheritance THttpCli - TComponent

THttpCli component is implementing the client side HTTP protocol described in RFC 1945 and RFC 2068. HTTP protocol is the standard protocol for browsing the World Wide Web. If you need an encrypted connection, use the SslHTTPCli component instead.

Properties

Accept Mime types accepted in the reply.
AcceptLanguage Languages accepted in the reply.
AcceptRanges Ranges accepted.
Agent User agent sent to server.
AuthorizationRequest List of authentication methods.
Connection Connection type for keep-alive.
ContentLength Received document length.
ContentRangeBegin Start of requested range.
ContentRangeEnd End of requested range.
ContentType Received document mime type.
ContentTypePost Sent document mime type.
Cookie Cookies to be sent.
CtrlSocket The underlying instance of TWSocket handles the connection and raw data exchange.
DnsResult Result of DNS request.
DocName Received document name.
FollowRelocation Tell the component o follow or not the relocations.
Handle Hidden window handle.
Hostname Hostname to which the URL point.
LastResponse Last response from server.
LocalAddr Local address to which underlying socket is bound.
Location Where the relocation will take place.
ModifiedSince Requested modification datetime.
MultiThreaded To tell the component it runs within a thread.
NoCache Tell the server to not cache the request.
Options Options.
Protocol Protocol extracted from the URL.
Proxy Proxy to traverse to before connecting. The IP address or hostname of the proxy server.
ProxyConnection Type of proxy connection. "Keep-Alive" or blank.
ProxyPort Port to be used to connect to proxy.
ProxyURL Combines four proxy properties as a URL for simplicity, i.e. http://[user[:password]@]host:port. Set ProxyAuth if that is required.
RcvdCount Bytes received.
RcvdHeader Received header.
RcvdStream Stream to receive a document.
ReasonPhrase Status returned by server.
Reference To send the referrer to the server.
RequestVer HTTP version to be used in the request.
Sender Sender to be sent to server.
SendStream Stream to be posted.
SentCount Bytes sent.
SocksAuthentication Socks server authentication type.
SocksLevel Sockers server protocol level.
SocksPassword Socks server password.
SocksPort Socks server port.
SocksServer Socks server hostname or IP.
SocksUsercode Socks server usercode.
State Component state.
StatusCode Server status code.
TransferEncoding Received document transfer encoding.
URL Complete URL to act on

Methods

Abort Abort the current operation.
Close Close the current connection (synchronous).
CloseAsync Close the current connection (asynchronous).
Create Create a new component instance.
Destroy Destroy the current component instance.
Get Request an URL using GET method (synchronous).
GetASync Request an URL using GET method (asynchronous).
Head Request the header for an URL (synchronous).
HeadASync Request the header for an URL (asynchronous).
Post Request an URL using the POST method (synchronous).
PostASync Request an URL using the POST method (asynchronous).
Put Request an URL using the PUT method (synchronous).
PutASync Request an URL using the PUT method (asynchronous).

Events

OnBeforeHeaderSend Triggered before the header is sent.
OnCommand Triggered for each command sent.
OnCookie Triggered when a cookie has been received.
OnDataPush Received data outside of any request.
OnDataPush2 Received data outside of a header.
OnDocBegin Triggered when the document part is about to be received.
OnDocData Triggered for each packet of the document part.
OnDocEnd Triggered when the document is complete.
OnHeaderBegin Triggered when the first header line is about to be received.
OnHeaderData Triggered for each received header line.
OnHeaderEnd Triggered when the header has been completely received.
OnLocationChange Triggered whenever the server sent a location change.
OnRequestDone Triggered when a request is completed.
OnRequestHeaderBegin Triggered when the first header line is about to be sent.
OnRequestHeaderEnd Triggered when the last header line has been sent.
OnSendBegin Triggered before sending document part.
OnSendData Triggered when sending document part.
OnSendEnd Triggered when document has been sent completely.
OnSessionClosed Triggered when the current connection has been closed.
OnSessionConnected Triggered when the connection has been openend.
OnSocketError Triggered when a socket error occured.
OnSocksConnected Triggered when connected to socks server.
OnSocksError Triggered when a error occurs with the socks server.
OnStateChange Triggered when component state change.

How to

How to implement a timeout for THttpCli in my application?

How to implement a progress for THttpCli in my application?

How to implement a download size limitation for THttpCli in my application?



ICS Components Reference