Difference between revisions of "THttpCli"
Jump to navigation
Jump to search
(15 intermediate revisions by 4 users not shown) | |||
Line 4: | Line 4: | ||
*'''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]] |||| | + | | 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]] |||| {{CtrlSocket}} | + | | 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. | + | | 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. | + | | valign="top" width="150" | [[THttpCli.RcvdCount | RcvdCount]] |||| Bytes received. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.RcvdHeader | RcvdHeader]] |||| Received header. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.RcvdStream | RcvdStream]] |||| Stream to receive a document. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.ReasonPhrase | ReasonPhrase]] |||| Status returned by server. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.Reference | Reference]] |||| To send the referrer to the server. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.RequestVer | RequestVer]] |||| HTTP version to be used in the request. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.Sender | Sender]] |||| Sender to be sent to server. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.SendStream | SendStream]] |||| Stream to be posted. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.SentCount | SentCount]] |||| Bytes sent. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.SocksAuthentication | SocksAuthentication]] |||| Socks server authentication type. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.SocksLevel | SocksLevel]] |||| Sockers server protocol level. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.SocksPassword | SocksPassword]] |||| Socks server password. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.SocksPort | SocksPort]] |||| Socks server port. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.SocksServer | SocksServer]] |||| Socks server hostname or IP. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.SocksUsercode | SocksUsercode]] |||| Socks server usercode. |
|- | |- | ||
− | | [[THttpCli. | + | | valign="top" width="150" | [[THttpCli.State | State]] |||| Component state. |
|- | |- | ||
− | | [[THttpCli. | + | | 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 111: | Line 113: | ||
{| | {| | ||
− | | valign="top" width="150" | [[THttpCli.Abort | Abort]] |||| | + | | 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]] |||| | + | | [[THttpCli.PutASync | PutASync]] |||| Request an URL using the PUT method (asynchronous). |
|} | |} | ||
Line 141: | Line 143: | ||
{| | {| | ||
− | | valign="top" width="150" | [[THttpCli.OnBeforeHeaderSend | OnBeforeHeaderSend]] |||| | + | | valign="top" width="150" | [[THttpCli.OnBeforeHeaderSend | OnBeforeHeaderSend]] |||| Triggered before the header is sent. |
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnCommand | OnCommand]] |||| Triggered for each command sent. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnCookie | OnCookie]] |||| Triggered when a cookie has been received. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnDataPush | OnDataPush]] |||| Received data outside of any request. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnDataPush2 | OnDataPush2]] |||| Received data outside of a header. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnDocBegin | OnDocBegin]] |||| Triggered when the document part is about to be received. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnDocData | OnDocData]] |||| Triggered for each packet of the document part. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnDocEnd | OnDocEnd]] |||| Triggered when the document is complete. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnHeaderBegin | OnHeaderBegin]] |||| Triggered when the first header line is about to be received. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnHeaderData | OnHeaderData]] |||| Triggered for each received header line. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnHeaderEnd | OnHeaderEnd]] |||| Triggered when the header has been completely received. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnLocationChange | OnLocationChange]] |||| Triggered whenever the server sent a location change. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnRequestDone | OnRequestDone]] |||| Triggered when a request is completed. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnRequestHeaderBegin | OnRequestHeaderBegin]] |||| Triggered when the first header line is about to be sent. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnRequestHeaderEnd | OnRequestHeaderEnd]] |||| Triggered when the last header line has been sent. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnSendBegin | OnSendBegin]] |||| Triggered before sending document part. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnSendData | OnSendData]] |||| Triggered when sending document part. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnSendEnd | OnSendEnd]] |||| Triggered when document has been sent completely. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnSessionClosed | OnSessionClosed]] |||| Triggered when the current connection has been closed. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnSessionConnected | OnSessionConnected]] |||| Triggered when the connection has been openend. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnSocketError | OnSocketError]] |||| Triggered when a socket error occured. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnSocksConnected | OnSocksConnected]] |||| Triggered when connected to socks server. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnSocksError | OnSocksError]] |||| Triggered when a error occurs with the socks server. |
|- | |- | ||
− | | [[THttpCli. | + | | [[THttpCli.OnStateChange | OnStateChange]] |||| Triggered when component state change. |
|} | |} | ||
Latest revision as of 15:45, 5 December 2019
Main page -> ICS components reference -> THttpCli
Contents
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?