Difference between revisions of "THttpCli"

From Overbyte
Jump to navigation Jump to search
 
(19 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS components reference]]
 +
-> [[THttpCli]]
 
== Overview ==
 
== Overview ==
  
 
*'''unit''' HttpProt.pas
 
*'''unit''' HttpProt.pas
*'''inheritance'''
+
*'''inheritance''' THttpCli - TComponent
  
THttpCli component is implementing the 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 ==
  
 
{|
 
{|
| valign="top" width="150" | [[THttpCli.Accept | Accept]] |||| Short description
+
| valign="top" width="150" | [[THttpCli.Accept | Accept]] |||| Mime types accepted in the reply.
 
|-
 
|-
| [[THttpCli.AcceptLanguage | AcceptLanguage]] ||||
+
| valign="top" width="150" | [[THttpCli.AcceptLanguage | AcceptLanguage]] |||| Languages accepted in the reply.
 
|-
 
|-
| [[THttpCli.AcceptRanges | AcceptRanges]] ||||
+
| valign="top" width="150" | [[THttpCli.AcceptRanges | AcceptRanges]] |||| Ranges accepted.
 
|-
 
|-
| [[THttpCli.Agent | Agent]] ||||
+
| valign="top" width="150" | [[THttpCli.Agent | Agent]] |||| User agent sent to server.
 
|-
 
|-
| [[THttpCli.AuthorizationRequest | AuthorizationRequest]] ||||
+
| valign="top" width="150" | [[THttpCli.AuthorizationRequest | AuthorizationRequest]] |||| List of authentication methods.
 
|-
 
|-
| [[THttpCli.Connection | Connection]] ||||
+
| valign="top" width="150" | [[THttpCli.Connection | Connection]] |||| Connection type for keep-alive.
 
|-
 
|-
| [[THttpCli.ContentLength | ContentLength]] ||||
+
| valign="top" width="150" | [[THttpCli.ContentLength | ContentLength]] |||| Received document length.
 
|-
 
|-
| [[THttpCli.ContentRangeBegin | ContentRangeBegin]] ||||
+
| valign="top" width="150" | [[THttpCli.ContentRangeBegin | ContentRangeBegin]] |||| Start of requested range.
 
|-
 
|-
| [[THttpCli.ContentRangeEnd | ContentRangeEnd]] ||||
+
| valign="top" width="150" | [[THttpCli.ContentRangeEnd | ContentRangeEnd]] |||| End of requested range.
 
|-
 
|-
| [[THttpCli.ContentType | ContentType]] ||||
+
| valign="top" width="150" | [[THttpCli.ContentType | ContentType]] |||| Received document mime type.
 
|-
 
|-
| [[THttpCli.ContentTypePost | ContentTypePost]] ||||
+
| valign="top" width="150" | [[THttpCli.ContentTypePost | ContentTypePost]] |||| Sent document mime type.
 
|-
 
|-
| [[THttpCli.Cookie | Cookie]] ||||
+
| valign="top" width="150" | [[THttpCli.Cookie | Cookie]] |||| Cookies to be sent.
 
|-
 
|-
| [[TWSocket | CtrlSocket]] |||| The underlying instance of [[TWSocket | TWSocket]] handles the connection and raw data exchange.
+
| valign="top" width="150" | [[TWSocket | CtrlSocket]] |||| {{CtrlSocket}}
 
|-
 
|-
| [[THttpCli.DnsResult | DnsResult]] ||||
+
| valign="top" width="150" | [[THttpCli.DnsResult | DnsResult]] |||| Result of DNS request.
 
|-
 
|-
| [[THttpCli.DocName | DocName]] ||||
+
| valign="top" width="150" | [[THttpCli.DocName | DocName]] |||| Received document name.
 
|-
 
|-
| [[THttpCli.FollowRelocation | FollowRelocation]] ||||
+
| valign="top" width="150" | [[THttpCli.FollowRelocation | FollowRelocation]] |||| Tell the component o follow or not the relocations.
 
|-
 
|-
| [[THttpCli.Handle | Handle]] ||||
+
| valign="top" width="150" | [[THttpCli.Handle | Handle]] |||| Hidden window handle.
 
|-
 
|-
| [[THttpCli.Hostname | Hostname]] ||||
+
| valign="top" width="150" | [[THttpCli.Hostname | Hostname]] |||| Hostname to which the URL point.
 
|-
 
|-
| [[THttpCli.LastResponse | LastResponse]] ||||
+
| valign="top" width="150" | [[THttpCli.LastResponse | LastResponse]] |||| Last response from server.
 
|-
 
|-
| [[THttpCli.LocalAddr | LocalAddr]] ||||
+
| valign="top" width="150" | [[THttpCli.LocalAddr | LocalAddr]] |||| Local address to which underlying socket is bound.
 
|-
 
|-
| [[THttpCli.Location | Location]] ||||
+
| valign="top" width="150" | [[THttpCli.Location | Location]] |||| Where the relocation will take place.
 
|-
 
|-
| [[THttpCli.ModifiedSince | ModifiedSince]] ||||
+
| valign="top" width="150" | [[THttpCli.ModifiedSince | ModifiedSince]] |||| Requested modification datetime.
 
|-
 
|-
| [[THttpCli.MultiThreaded | MultiThreaded]] ||||
+
| valign="top" width="150" | [[THttpCli.MultiThreaded | MultiThreaded]] |||| To tell the component it runs within a thread.
 
|-
 
|-
| [[THttpCli.NoCache | NoCache]] ||||
+
| valign="top" width="150" | [[THttpCli.NoCache | NoCache]] |||| Tell the server to not cache the request.
 
|-
 
|-
| [[THttpCli.Options | Options]] ||||
+
| valign="top" width="150" | [[THttpCli.Options | Options]] |||| Options.
 
|-
 
|-
| [[THttpCli.Protocol | Protocol]] ||||
+
| valign="top" width="150" | [[THttpCli.Protocol | Protocol]] |||| Protocol extracted from the URL.
 
|-
 
|-
| [[THttpCli.Proxy | Proxy]] ||||
+
| valign="top" width="150" | [[THttpCli.Proxy | Proxy]] |||| Proxy to traverse to before connecting. The IP address or hostname of the proxy server.
 
|-
 
|-
| [[THttpCli.ProxyConnection | ProxyConnection]] ||||
+
| valign="top" width="150" | [[THttpCli.ProxyConnection | ProxyConnection]] |||| Type of proxy connection. "Keep-Alive" or blank.
 
|-
 
|-
| [[THttpCli.ProxyPort | ProxyPort]] ||||
+
| valign="top" width="150" | [[THttpCli.ProxyPort | ProxyPort]] |||| Port to be used to connect to proxy.
 
|-
 
|-
| [[THttpCli.RcvdCount | RcvdCount]] ||||
+
| 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.
 
|-
 
|-
| [[THttpCli.RcvdHeader | RcvdHeader]] ||||
+
| valign="top" width="150" | [[THttpCli.RcvdCount | RcvdCount]] |||| Bytes received.
 
|-
 
|-
| [[THttpCli.RcvdStream | RcvdStream]] ||||
+
| valign="top" width="150" | [[THttpCli.RcvdHeader | RcvdHeader]] |||| Received header.
 
|-
 
|-
| [[THttpCli.ReasonPhrase | ReasonPhrase]] ||||
+
| valign="top" width="150" | [[THttpCli.RcvdStream | RcvdStream]] |||| Stream to receive a document.
 
|-
 
|-
| [[THttpCli.Reference | Reference]] ||||
+
| valign="top" width="150" | [[THttpCli.ReasonPhrase | ReasonPhrase]] |||| Status returned by server.
 
|-
 
|-
| [[THttpCli.RequestVer | RequestVer]] ||||
+
| valign="top" width="150" | [[THttpCli.Reference | Reference]] |||| To send the referrer to the server.
 
|-
 
|-
| [[THttpCli.Sender | Sender]] ||||
+
| valign="top" width="150" | [[THttpCli.RequestVer | RequestVer]] |||| HTTP version to be used in the request.
 
|-
 
|-
| [[THttpCli.SendStream | SendStream]] ||||
+
| valign="top" width="150" | [[THttpCli.Sender | Sender]] |||| Sender to be sent to server.
 
|-
 
|-
| [[THttpCli.SentCount | SentCount]] ||||
+
| valign="top" width="150" | [[THttpCli.SendStream | SendStream]] |||| Stream to be posted.
 
|-
 
|-
| [[THttpCli.SocksAuthentication | SocksAuthentication]] ||||
+
| valign="top" width="150" | [[THttpCli.SentCount | SentCount]] |||| Bytes sent.
 
|-
 
|-
| [[THttpCli.SocksLevel | SocksLevel]] ||||
+
| valign="top" width="150" | [[THttpCli.SocksAuthentication | SocksAuthentication]] |||| Socks server authentication type.
 
|-
 
|-
| [[THttpCli.SocksPassword | SocksPassword]] ||||
+
| valign="top" width="150" | [[THttpCli.SocksLevel | SocksLevel]] |||| Sockers server protocol level.
 
|-
 
|-
| [[THttpCli.SocksPort | SocksPort]] ||||
+
| valign="top" width="150" | [[THttpCli.SocksPassword | SocksPassword]] |||| Socks server password.
 
|-
 
|-
| [[THttpCli.SocksServer | SocksServer]] ||||
+
| valign="top" width="150" | [[THttpCli.SocksPort | SocksPort]] |||| Socks server port.
 
|-
 
|-
| [[THttpCli.SocksUsercode | SocksUsercode]] ||||
+
| valign="top" width="150" | [[THttpCli.SocksServer | SocksServer]] |||| Socks server hostname or IP.
 
|-
 
|-
| [[THttpCli.State | State]] ||||
+
| valign="top" width="150" | [[THttpCli.SocksUsercode | SocksUsercode]] |||| Socks server usercode.
 
|-
 
|-
| [[THttpCli.StatusCode | StatusCode]] ||||
+
| valign="top" width="150" | [[THttpCli.State | State]] |||| Component state.
 
|-
 
|-
| [[THttpCli.TransferEncoding | TransferEncoding]] ||||
+
| valign="top" width="150" | [[THttpCli.StatusCode | StatusCode]] |||| Server status code.
 
|-
 
|-
| [[THttpCli.URL | URL]] |||| Complete URL to act on
+
| valign="top" width="150" | [[THttpCli.TransferEncoding | TransferEncoding]] |||| Received document transfer encoding.
 +
|-
 +
| valign="top" width="150" | [[THttpCli.URL | URL]] |||| Complete URL to act on
 
|}
 
|}
  
Line 109: 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 139: 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.
 
|}
 
|}
  
Line 199: Line 199:
  
 
[[THttpCli.FAQ.SizeLimit | How to implement a download size limitation for THttpCli in my application?]]
 
[[THttpCli.FAQ.SizeLimit | How to implement a download size limitation for THttpCli in my application?]]
 +
 +
{{Components_Footer}}

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