/trunk/Common/Overbyte ICS 7/OverbyteIcsHttpProt.pas

http://castlesand.googlecode.com/ · Pascal · 5003 lines · 3286 code · 356 blank · 1361 comment · 557 complexity · 72aa1ad415fc0ebf881a218f47d9a840 MD5 · raw file

Large files are truncated click here to view the full file

  1. {*_* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. Author: François PIETTE
  3. Creation: November 23, 1997
  4. Version: 7.08
  5. Description: THttpCli is an implementation for the HTTP protocol
  6. RFC 1945 (V1.0), and some of RFC 2068 (V1.1)
  7. Credit: This component was based on a freeware from by Andreas
  8. Hoerstemeier and used with his permission.
  9. andy@hoerstemeier.de http://www.hoerstemeier.com/index.htm
  10. EMail: francois.piette@overbyte.be http://www.overbyte.be
  11. Support: Use the mailing list twsocket@elists.org
  12. Follow "support" link at http://www.overbyte.be for subscription.
  13. Legal issues: Copyright (C) 1997-2010 by François PIETTE
  14. Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
  15. <francois.piette@overbyte.be>
  16. SSL implementation includes code written by Arno Garrels,
  17. Berlin, Germany, contact: <arno.garrels@gmx.de>
  18. This software is provided 'as-is', without any express or
  19. implied warranty. In no event will the author be held liable
  20. for any damages arising from the use of this software.
  21. Permission is granted to anyone to use this software for any
  22. purpose, including commercial applications, and to alter it
  23. and redistribute it freely, subject to the following
  24. restrictions:
  25. 1. The origin of this software must not be misrepresented,
  26. you must not claim that you wrote the original software.
  27. If you use this software in a product, an acknowledgment
  28. in the product documentation would be appreciated but is
  29. not required.
  30. 2. Altered source versions must be plainly marked as such, and
  31. must not be misrepresented as being the original software.
  32. 3. This notice may not be removed or altered from any source
  33. distribution.
  34. 4. You must register this software by sending a picture postcard
  35. to the author. Use a nice stamp and mention your name, street
  36. address, EMail address and any comment you like to say.
  37. Quick Reference:
  38. HTTP component can retrieve documents or files using HTTP protocol; that is
  39. connect to a HTTP server also known as a webserver. It can also trigger a
  40. CGI/ISAPI/NSAPI script and post data using either GET or POST method.
  41. Syntax of an URL: protocol://[user[:password]@]server[:port]/path
  42. Path can include data: question mark followed by URL encoded data.
  43. HTTP component is either asynchonous (non-blocking) or synchonous (blocking).
  44. Highest performance is when using asynchonous operation. This is the
  45. recommended way to use HTTP component.
  46. To request several URL simultaneously, use asynchronous operation and as much
  47. HTTP components as you wants to request URLs. All requests will be executed
  48. simultaneously without using multi-threading and without blocking your app.
  49. Methods:
  50. GetASync Asynchronous, non-blocking Get
  51. Retrieve document or file specified by URL, without blocking.
  52. OnRequestDone event trigered when finished. Use HTTP GET
  53. method (data contained in URL)
  54. PostASync Asynchronous, non-blocking Post
  55. Retrieve document or file specified by URL, without blocking.
  56. OnRequestDone event trigered when finished. Use HTTP POST
  57. method (data contained in request stream)
  58. HeadASync Asynchronous, non-blocking Head
  59. Retrieve document or file header specified by URL, without
  60. blocking. OnRequestDone event trigered when finished. Use HTTP
  61. HEAD method.
  62. Get Synchronous, blocking Get. Same as GetAsync, but blocks until
  63. finished.
  64. Post Synchronous, blocking Post. Same as PostAsync, but blocks until
  65. finished.
  66. Head Synchronous, blocking Head. Same as HeadAsync, but blocks until
  67. finished.
  68. Abort Immediately close communication.
  69. Updates:
  70. 11/29/97 RcvdStream and SendStream properties moved to public section
  71. 11/30/97 Document name bug corrected
  72. 12/02/97 Removed bug occuring with terminating slash in docname
  73. 12/03/97 Added properties RcvdCount and SentCount to easily add a progress
  74. bar feature (On receive, the ContentLength is initialized with the
  75. value from the header. Update the progress bar in the OnDocData event,
  76. or the OnSendData event).
  77. Added the OnSendBegin, OnSendData and OnSendEnd events.
  78. 12/07/97 Corrected Head function to work as expected. Thanks to
  79. R. Barry Jones <rbjones@therightside.demon.co.uk
  80. 29/12/97 V0.96 Added ModifiedSince property as following proposition made by
  81. Aw Kong Koy" <infomap@tm.net.my>.
  82. 30/12/97 V0.97 Added a Cookie property to send cookies
  83. 11/01/98 V0.98 Added WSocket read-only property which enable to access the
  84. socket component used internally. For example to close it to abort
  85. a connection.
  86. 13/01/98 V0.99 Added MultiThreaaded property to tell the component that it is
  87. working in a thread and should take care of it.
  88. 15/01/98 V1.00 Completely revised internal working to make it work properly
  89. with winsock 2. The TimeOut property is gone.
  90. Changed OnAnswerLine event to OnHeaderData to be more consistent.
  91. Replaced AnswserLine property by readonly LastResponse property.
  92. Added OnRequestDone event. Added GetAsync, PostAsync, HeadAsync
  93. asynchronous, non-blocking methods. Added Abort procedure.
  94. 16/01/98 V1.01 Corrected a bug which let some data be lost when receiving
  95. (thanks to Fulvio J. Castelli <fulvio@rocketship.com>)
  96. Added test for HTTP/1.1 response in header.
  97. 31/01/98 V1.02 Added an intermediate message posting for the OnRequestDone
  98. event. Thanks to Ed Hochman <ed@mbhsys.com> for his help.
  99. Added an intermediate PostMessage to set the component to ready state.
  100. 04/02/98 V1.03 Added some code to better handle DocName (truncating at the
  101. first question mark).
  102. 05/02/98 V1.04 Deferred login after a relocation, using WM_HTTP_LOGIN message.
  103. Added workarounf to support faulty webservers which sent only a single
  104. LF in header lines. Submitted by Alwin Hoogerdijk <alwin@lostboys.nl>
  105. 15/03/98 V1.05 Enlarge buffers from 2048 to 8192 bytes (not for D1)
  106. 01/04/98 V1.06 Adapted for BCB V3
  107. 13/04/98 V1.07 Made RcvdHeader property readonly and cleared the content at the
  108. start of a request.
  109. Protected Abort method from calling when component is ready.
  110. Ignore any exception triggered by CancelDnsLookup in Abort method.
  111. 14/04/98 V1.08 Corrected a relocation bug occuring with relative path
  112. 26/04/98 V1.09 Added OnLocationChange event
  113. 30/04/98 V1.10 Added ProxyUsername and ProxyPassword. Suggested by
  114. Myers, Mike <MikeMy@crt.com>.
  115. 26/05/98 V1.11 Corrected relocation problem when used with ASP webpages
  116. 09/07/98 V1.12 Adapted for Delphi 4
  117. Checked argument length in SendCommand
  118. 19/09/98 V1.13 Added support for HTML document without header
  119. Added OnSessionConnected event, httpConnected state and
  120. httpDnsLookupDone state.
  121. Corrected a problem with automatic relocation. The relocation
  122. message was included in data, resulting in wrong document data.
  123. Added two new events: OnRequestHeaderBegin and OnRequestHeaderEnd.
  124. They replace the OnHeaderBegin and OnHeaderEnd events that where
  125. called for both request header (to web server) and response
  126. header (from web server)
  127. 22/11/98 V1.14 Added a Location property than gives the new location in
  128. case of page relocation. Suggested by Jon Robertson <touri@pobox.com>
  129. 21/12/98 V1.15 Set ContentLength equal to -1 at start of command.
  130. 31/01/99 V1.16 Added HostName property
  131. 01/02/99 V1.17 Port was lost in DoRequestAsync when using a proxy.
  132. Thanks to David Wright <wrightd@gamespy.com> for his help.
  133. Report Dns lookup error and session connect error in OnrequestDOne
  134. event handler as suggested by Jack Olivera <jack@token.nl>.
  135. 14/03/99 V1.18 Added OnCookie event.
  136. 16/03/99 V1.19 Added Accept property.
  137. Added a default value to Agent property.
  138. Changed OnCookie event signature (not fully implemented yet !).
  139. 07/05/99 V1.20 Added code to support Content Ranges by Jon Robertson
  140. <touri@pobox.com>.
  141. 24/07/99 V1.21 Yet another change in relocation code.
  142. Aug 20, 1999 V1.22 Changed conditional compilation so that default is same
  143. as latest compiler (currently Delphi 4, Bcb 4). Should be ok for
  144. Delphi 5. Added Sleep(0) in sync wait loop to reduce CPU usage.
  145. Added DnsResult property as suggested by Heedong Lim
  146. <hdlim@dcenlp.chungbuk.ac.kr>. This property is accessible from
  147. OnStateChange when state is httpDnsLookupDone.
  148. Triggered OnDocData after writing to the stream.
  149. Sep 25, 1999 V1.23 Yet another change in relocation code when using proxy
  150. Francois Demers <fdemers@videotron.ca> found that some webserver
  151. do not insert a space after colon in header line. Corrected
  152. code to handle it correctly.
  153. Cleared ContentType before issuing request.
  154. Oct 02, 1999 V1.24 added AcceptRanges property. Thanks to Werner Lehmann
  155. <wl@bwl.uni-kiel.de>
  156. Oct 30, 1999 V1.25 change parameter in OnCommand event from const to var to
  157. allow changing header line, including deleting or adding before
  158. or after a given line sent by the component.
  159. Nov 26, 1999 V1.26 Yet another relocation fix !
  160. Jun 23, 2000 V1.27 Fixed a bug in ParseURL where hostname is followed by a '?'
  161. (that is no path but a query).
  162. Jul 22, 2000 V1.28 Handle exception during DnsLookup from the login procedure.
  163. Suggested by Robert Penz <robert.penz@outertech.com>
  164. Sep 17, 2000 V1.29 Eugene Mayevski <Mayevski@eldos.org> added support for
  165. NOFORMS.
  166. Jun 18, 2001 V1.30 Use AllocateHWnd and DeallocateHWnd from wsocket.
  167. Renamed property WSocket to CtrlSocket (this require code change
  168. in user application too).
  169. Jul 25, 2001 V1.31 Danny Heijl <Danny.Heijl@cevi.be> found that ISA proxy adds
  170. an extra space to the Content-length header so we need a trim
  171. to extract numeric value.
  172. Ran Margalit <ran@margalit.com> found some server sending
  173. empty document (Content-Length = 0) which crashed the component.
  174. Added a check for that case when header is finished.
  175. Andrew N.Silich" <silich@rambler.ru> found we need to handle
  176. handle relative path using "../" and "./" when relocating. Thanks
  177. for his code which was a good starting point.
  178. Jul 28, 2001 V1.32 Sahat Bun <sahat@operamail.com> suggested to change POST to
  179. GET when a relocation occurs.
  180. Created InternalClear procedure as suggested by Frank Plagge
  181. <frank@plagge.net>.
  182. When relocation, clear FRcvdHeader. If port not specified, then
  183. use port 80. By Alexander O.Kazachkin <kao@inreco.ru>
  184. Jul 30, 2001 V1.33 Corected a few glitches with Delphi 1
  185. Aug 18, 2001 V1.34 Corrected a bug in relocation logic: when server send only a
  186. header, with no document at all, relocation was not occuring and
  187. OnHeaderEnd event was not triggered.
  188. Corrected a bug in document name when a CGI was invoked (a '?'
  189. found in the URL). Now, ignore everything after '?' which is CGI
  190. parameter.
  191. Sep 09, 2001 V1.35 Beat Boegli <leeloo999@bluewin.ch> added LocalAddr property
  192. for multihomed hosts.
  193. Sep 29, 2001 V1.36 Alexander Alexishin <sancho@han.kherson.ua> corrected
  194. ParseUrl to handle the case where http:// is not at start of url:
  195. 'first.domain.com/cgi-bin/serv?url=http://second.domain.com'
  196. Yet another relocation code change.
  197. Oct 28, 2001 V1.37 Corrected SocketSessionClosed which called
  198. LocationSessionClosed when it was not needed.
  199. Nov 10, 2001 V1.38 Fixed a bug where component was trying to connect to proxy
  200. using default port instead on specified port after a relocation.
  201. Corrected a bug when relocating to a relative path. Current path
  202. was not taken into account !
  203. Mar 06, 2002 V1.39 Fixed a bug in relocation when content-length was 0: no
  204. relocation occured ! (Just check for relocation before checking
  205. content length empty).
  206. Mar 12, 2002 V1.40 Added UrlEncode and UrlDecode utility functions.
  207. Mar 30, 2002 V1.41 Export a few utility functions: IsDigit, IsXDigit, XDigit,
  208. htoin and htoi2.
  209. Apr 14, 2002 V1.42 Paolo S. Asioli <paolo.asioli@libero.it> found a bug in
  210. relocation code where new user/pass are specified.
  211. On relocation, change DocName according to the relocation.
  212. When DocName has no extension and ContentType is text/html the
  213. add extension .htm (could be expanded do other content type)
  214. Apr 20, 2002 V1.43 Added Socks code from Eugene Mayevski <mayevski@eldos.org>
  215. Apr 21, 2002 V1.44 In LocationSessionClosed, clear status variables from
  216. previous operation.
  217. Sep 06, 2002 V1.45 Made a few more methods virtual.
  218. Sep 10, 2002 V1.46 Added AcceptLanguage property.
  219. Sep 11, 2002 V1.47 Wilfried Mestdagh <wilfried@mestdagh.biz> added
  220. OnBeforeHeaderSend event to help add/remove/change header lines.
  221. He also corrected SocketSessionClosed to report error code.
  222. Feb 08, 2003 V1.48 Implemented more HTTP/1.1 features notably TCP session
  223. persistance.
  224. Feb 22, 2003 V1.49 Corrected a bug related to document length computation.
  225. Thanks to Dav999 <transmaster@ifrance.com> who found a
  226. reproductible case with perso.wanadoo.fr webserver.
  227. Apr 27, 2003 V1.50 OnLocationChange was not called when a relocation occured
  228. and server handle HTTP/1.1 and new location on same server.
  229. May 01, 2003 V1.51 Location and URL properties where incorrect after relocation
  230. to same HTTP/1.1 server.
  231. Change POST to GET after relocation to same HTTP/1.1 server.
  232. May 09, 2003 V1.52 Implemented PUT method
  233. May 31, 2003 V1.53 Corrected a problem with relocation when a proxy was used
  234. and a relative path was given.
  235. Aug 21, 2003 V1.54 Removed HTTPCliDeallocateHWnd virtual attribute for BCB
  236. because of a bug in BCB preventing linking any derived
  237. component with a HWND argument in a virtual method.
  238. With help from Steven S. Showers and Stanislav Korotky.
  239. Nov 26, 2003 V1.55 Implemented OnDataPush event for server push handling.
  240. Added OnSessionClosed event.
  241. Corrected ParseUrl to correctly handle protocol specified in
  242. uppercase. Thanks to "Nu Conteaza" <osfp@personal.ro>.
  243. Implemented OnDataPush2 event. Not the same as OnDataPush:
  244. OnDataPush: Need to call Receive to get data
  245. OnDataPush2: Data already received and delivered in LastResponse
  246. Dec 28, 2003 V1.56 Implemented TransferEncoding = chunked
  247. Moved code for relocation after document receive so that even in
  248. case of a relocation, any available document is preserved.
  249. Thanks to Steve Endicott <Endi@pacbell.net> for his help.
  250. Jan 09, 2004 V1.57 Fixed a relocation not done when end of document is in the
  251. same data packet as the last header line. With help of S. Endicott.
  252. Steve Endicott <Endi@pacbell.net> implemented "Connection: close"
  253. header line.
  254. Jan 12, 2004 V1.58 "Ted T?raasen" <Ted@extreme.no> added proprety
  255. FollowRelocation (default to TRUE) to have the component follow
  256. relocation or just ignore them.
  257. Jan 15, 2004 V1.59 Set FRcvdCount to zero in StartRelocation (S. Endicott).
  258. Started to implement NTLM authentication. Doesn't work yet !
  259. Jan 26, 2004 V1.60 Reordered uses clause for FPC compatibility.
  260. Feb 16, 2004 V1.61 Fixed GetHeaderLineNext to start relocation at the right
  261. moment. See annotation "16/02/2004".
  262. Mar 12, 2004 Fixed GetHeaderLineNext to check for StatusCode < 200, 204 and
  263. 304 in order to not wait for body.
  264. Thanks to Csonka Tibor <bee@rawbite.ro> for finding a test case.
  265. Jul 12, 2004 Just this warning: The component now doesn't consider 401 status
  266. as a fatal error (no exception is triggered). This required a
  267. change in the application code if it was using the exception that
  268. is no more triggered for status 401.
  269. Jul 18, 2004 V1.63 Use CompareText to check for http string is relocation
  270. header. Thanks to Roger Tinembart <tinembart@brain.ch>
  271. Jul 23, 2004 V1.64 Fixed a line too long exception when requesting HEAD or URL
  272. http://de.news.yahoo.com:80/. The server was sending a document
  273. even after we requested just the header. The fix make the
  274. component ignore data and abort the connection. This is really an
  275. error at server side !
  276. Aug 08, 2004 V1.65 Moved utility function related to URL handling into IcsUrl
  277. unit for easy reuse outside of the component.
  278. Aug 20, 2004 V1.66 Use MsgWaitForMultipleObjects in DoRequestSync to avoid
  279. consumming 100% CPU while waiting.
  280. Sep 04, 2004 V1.67 Csonka Tibor <bee@rawbite.ro> worked a lot on my NTLM code,
  281. fixing it and making it work properly.
  282. I removed NTLM specific usercode and password properties to use
  283. FUsername and FPassword which are extracted from the URL.
  284. Define symbol UseNTLMAuthentication for Delphi 5 and up.
  285. Sep 13, 2004 V1.68 Added option httpoNoNTLMAuth by Csonka Tibor
  286. Fixed TriggerRequestDone for NTLM authentication
  287. Moved NTLM code out of DoBeforeConnect which was intended for
  288. socket setup and not for protocol handling.
  289. Oct 02, 2004 V1.69 Removed second copy of IntToStrDef.
  290. Oct 06, 2004 V1.70 Miha Remec fixed THttpCli.GetHeaderLineNext to add
  291. status check for 301 and 302 values.
  292. Oct 15, 2004 V1.71 Lotauro.Maurizio@dnet.it enhanced basic and NTLM
  293. authentifications methods. Event OnNTLMAuthStep has been
  294. removed. Now basic authentication is not automatically sent with
  295. a request. It is only sent when the server request it by replying
  296. with a 401 or 407 response. Sending basic authentication in the
  297. first request was a kind of security threat for NTLM:
  298. usercode/password is sent unencrypted while NTLM is made to send
  299. it encrypted (DES). This has the side effect of requiring two
  300. request where one was needed. This could be a problem when posting
  301. data: data has to be posted twice ! This is transparent to the user
  302. except for performance :-( A future enhancement could be a new
  303. option to always send basic authentication.
  304. Oct 30, 2004 V1.72 Made SendRequest virtual.
  305. Nov 07, 2004 V1.73 Added CleanupRcvdStream. Lotauro.Maurizio@dnet.it found that
  306. document must be cleaned if received in intermediate authentication
  307. steps.
  308. Nov 09, 2004 V1.74 Cleared FDoAuthor from InternalClear. Thanks Maurizio.
  309. Nov 11, 2004 V1.75 Added CleanupRcvdStream when starting relocation.
  310. Thanks Maurizio.
  311. Removed second TriggerHeaderEnd in GetHeaderLineNext.
  312. Thanks Ronny Karl for finding this one.
  313. Nov 20, 2004 V1.76 Angus Robertson found a problem with SendStream because of
  314. authentication (post restarted because authentication need to be
  315. done).
  316. Maurizio fixed the issue above an a fix others:
  317. - added a CleanupSendStream procedure, and added a call to it in
  318. every place where the CleanupRcvdStream is called.
  319. - changed the Content-Length calculation: if the position of the
  320. stream is not 0 then the length was wrong
  321. - changed the the test in DoRequestAsync: if the position of the
  322. stream is at the end then it will send nothing
  323. Nov 22, 2004 V1.77 Only a single error code for httperrInvalidAuthState.
  324. Dec 14, 2004 V1.78 Excluded code 407 and added code 400 in DoRequestSync
  325. Dec 19, 2004 V1.79 Revised CleanupRcvdStream to make it compatible with D1.
  326. Dec 22, 2004 V1.80 Changed SocketDataAvailable so that header lines that are
  327. too long to fit into the receive buffer (8K) are simply truncated
  328. instead of triggering an exception.
  329. Jan 05, 2005 V1.81 Maurizio Lotauro <Lotauro.Maurizio@dnet.it> optimized NTLM
  330. authentication by not sending content in the first step.
  331. Jan 29, 2005 V1.82 Fixed socks properties propagation to control socket.
  332. Feb 05, 2005 V1.83 Fixed GetHeaderLineNext in the case Abort is called from
  333. OnHeaderEnd event (Bug reported by Csonka Tibor).
  334. Fixed relocation to https destination when USE_SSL is not
  335. defined. It is handled as a non implemented protocol.
  336. Mar 19, 2005 V1.84 Changed CleanupRcvdStream to check for COMPILER3_UP instead
  337. of checking DELPHI3_UP (BCB compatibility issue).
  338. Changed StrToIntDef to check for COMPILER5_UP instead of
  339. DELPHI5_UP (BCB compatibility issue). Thanks to Albert Wiersch.
  340. Mar 21, 2005 V1.85 Added port in "host:" header line as suggested by Sulimov
  341. Valery <99valera99@rambler.ru>.
  342. In DoRequestAsync, allow to continue even with no data to be sent.
  343. Apr 14, 2005 V1.86 Fixed PrepareBasicAuth to ignore charcase when checking for
  344. 'basic' keyword in header line. Thanks to abloms@yahoo.com for
  345. finding this bug which affected use thru iPlanet Web Proxy Server.
  346. Apr 16, 2005 V1.87 Applyed the fix above to PrepareNTLMAuth (two places),
  347. StartAuthNTLM and StartProxyAuthNTLM.
  348. May 26, 2005 V1.88 Fixed DoRequestAsync to set http as default protocol.
  349. Aug 15, 2005 V1.89 Implemented bandwidth control for download (Get).
  350. Oct 31, 2005 V1.89a rework of authentication handling to fix a problem that could
  351. happen when both proxy and remote server needed an authentication
  352. causing an infinite loop, by Maurizio Lotauro
  353. - removed the TXXXAuthType type and the variables of that types
  354. - properties Username and Password will no more replaced by the
  355. credential contained in the URL. Two new variables are introduced
  356. FCurrUsername and FCurrPassword. These will contain the credential
  357. in the URL (if specified), otherwise the content of the property.
  358. - same logic for Connection and ProxyConnection (introduced
  359. FCurrConnection and FCurrProxyConnection)
  360. Nov 19, 2005 V1.89b supports SSL v5 by Arno Garrels
  361. Nov 27, 2005 V1.90 implemented redirection limiting to avoid continuous
  362. looping to same URL, by Angus Robertson, Magenta Systems
  363. test example is http://www.callserve.com/ that keeps looping
  364. Implemented ContentEncoding (can be disabled with define
  365. UseContentCoding), mostly done in new HttpContCod.pas,
  366. add HttpCCodzlib to your project for GZIP compression support,
  367. and set httpoEnableContentCoding in Options to enable it
  368. by Maurizio Lotauro <Lotauro.Maurizio@dnet.it>
  369. Dec 20, 2005 V1.91 new configurable DebugOptions to replace IFDEF DEBUG_OUTPUT,
  370. see wsocket for more information
  371. Apr 10, 2006 V6.00.1 Added LowerCase for FTransferEncoding? Thanks to Fastream.
  372. Dec 10, 2006 V6.00.2 Jack <jlist9@gmail.com> fixed BandwidthTimerTimer to clear
  373. the count.
  374. Mar 17, 2007 V6.00.3 Introduced THttpBigInt to support documents longer
  375. than 2GB.
  376. Mar 19, 2007 V6.00.3 A.Garrels fixed a memory leak of FSendBuffer and
  377. FReceiveBuffer. Check for negative value of FReceiveLen in
  378. SocketDataAvailable.
  379. May 27, 2008 V6.00.4 A.Garrels Workaround in GetHeaderLineNext. Ignore body data
  380. sent in the HEAD response by buggy servers.
  381. Jun 25, 2008 V6.00.5 A. Garrels SSL code merged.
  382. Jul 17, 2008 V6.00.6 A. Garrels made a few changes to prepare code for Unicode,
  383. added OverbyteIcsUtils to the uses clause, optimized
  384. MoveTBytesToString a bit, removed some stuff for older compilers,
  385. removed typedef of TBytes, now uses TBytes of OverbyteIcsTypes.pas.
  386. Sep 28, 2008 V6.00.7 Maurizio Lotauro fixed a bug with premature received
  387. 401/407 responses while data was still being sent with POST and PUT
  388. requests. A. Garrels small fix in SendCommand().
  389. Sep 29, 2008 V6.00.8 A. Garrels added OverbyteIcsUtils to the uses clause
  390. for all compilers.
  391. Dec 06, 2008 V7.00.9 A. Garrels fixed function EncodeStr and EncodeLine.
  392. Jan 11, 2009 V7.01 A. Garrels fixed a bug with proxies which do not
  393. send a Content-Length header in non-persistent connections by
  394. simply always setting FReceiveLen to zero in SocketSessionClosed.
  395. Jan 11, 2009 V7.02 A. Garrels - Added Digest Access Authentication.
  396. In order to disable this feature entirely undefine directive
  397. UseDigestAuthentication below.
  398. Added new event OnBeforeAuth that can be used to skip internal
  399. authorization by setting argument Allow to FALSE.
  400. ** Also cleaned up the source code a bit, thus a comparison
  401. with previous version, unfortunately won't be fun. **
  402. Jan 12, 2009 V7.02a Arno added two missing lines for digest auth to the SSL code.
  403. Jan 22, 2009 V7.02b Sorry guys! Re-added property OnBeforeHeaderSend again
  404. which I (Arno) removed in V7.02 accidently :(
  405. Jan 22, 2009 V7.02c Arno - Conditional define UseDigestAuthentication was not
  406. set properly in THttpCli.StateChange.
  407. Apr 25, 2009 V7.03 Steve Endicott fixed a relocation bug with HTTPS.
  408. Sep 17, 2009 V7.04 Arno added property Timeout, works only with synchronous
  409. methods!
  410. Dec 02, 2009 V7.05 Bjornar found a HTTPS POST bug with proxy basic
  411. authentication that added two Content-Length header lines.
  412. Feb 15, 2010 V7.06 Yuri Semenov fixed a bug with content coding and chunked
  413. transfer encoding.
  414. Feb 25, 2010 V7.07 Fix by Bj?rnar Nielsen: TSslHttpCli didn't work when used
  415. against Websense-Content_Gateway (http://www.websense.com) and
  416. some others. The problem was that this (and some other proxies too)
  417. answer 200 OK to notify client that connection to remote server
  418. is established. Usually proxies use 200 OK and an error text when
  419. something is wrong. In that case Content-Length is not 0.
  420. May 24, 2010 V7.08 Angus ensure Ready when relocations exceed maximum to avoid timeout
  421. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
  422. unit OverbyteIcsHttpProt;
  423. interface
  424. {$I OverbyteIcsDefs.inc}
  425. {$IFDEF COMPILER14_UP}
  426. {$IFDEF NO_EXTENDED_RTTI}
  427. {$RTTI EXPLICIT METHODS([]) FIELDS([]) PROPERTIES([])}
  428. {$ENDIF}
  429. {$ENDIF}
  430. {$IFNDEF COMPILER7_UP}
  431. 'Sorry, we do not want to support ancient compilers any longer'
  432. {$ENDIF}
  433. {$IFDEF DELPHI6_UP}
  434. {$WARN SYMBOL_PLATFORM OFF}
  435. {$WARN SYMBOL_LIBRARY OFF}
  436. {$WARN SYMBOL_DEPRECATED OFF}
  437. {$ENDIF}
  438. {$B-} { Enable partial boolean evaluation }
  439. {$T-} { Untyped pointers }
  440. {$X+} { Enable extended syntax }
  441. {$H+} { Use long strings }
  442. {$J+} { Allow typed constant to be modified }
  443. {$IFDEF BCB3_UP}
  444. {$ObjExportAll On}
  445. {$ENDIF}
  446. {$IFNDEF NO_ADVANCED_HTTP_CLIENT_FEATURES}
  447. {$DEFINE UseNTLMAuthentication}
  448. {$DEFINE UseDigestAuthentication}
  449. {$DEFINE UseBandwidthControl}
  450. {$DEFINE UseContentCoding}
  451. {$ENDIF}
  452. {$IFDEF CLR}
  453. {$UNDEF UseNTLMAuthentication}
  454. {$UNDEF UseDigestAuthentication}
  455. {$UNDEF UseContentCoding}
  456. {$ENDIF}
  457. uses
  458. Messages,
  459. {$IFDEF USEWINDOWS}
  460. Windows,
  461. {$ELSE}
  462. WinTypes, WinProcs,
  463. {$ENDIF}
  464. {$IFDEF CLR}
  465. System.Text, System.IO, System.Threading,
  466. {$ENDIF}
  467. SysUtils, Classes,
  468. {$IFNDEF NOFORMS}
  469. Forms, Controls,
  470. {$ENDIF}
  471. { You must define USE_SSL so that SSL code is included in the component. }
  472. { Either in OverbyteIcsDefs.inc or in the project/package options. }
  473. {$IFDEF USE_SSL}
  474. OverbyteIcsSSLEAY, OverbyteIcsLIBEAY,
  475. {$ENDIF}
  476. {$IFDEF UseNTLMAuthentication}
  477. OverbyteIcsNtlmMsgs,
  478. {$ENDIF}
  479. {$IFDEF UseContentCoding}
  480. OverbyteIcsHttpContCod,
  481. {$ENDIF}
  482. {$IFNDEF NO_DEBUG_LOG}
  483. OverbyteIcsLogger,
  484. {$ENDIF}
  485. OverbyteIcsUrl, OverbyteIcsTypes,
  486. OverbyteIcsUtils,
  487. {$IFDEF UseDigestAuthentication}
  488. OverbyteIcsDigestAuth,
  489. {$ENDIF}
  490. OverbyteIcsWinSock, OverbyteIcsWndControl, OverbyteIcsWSocket;
  491. const
  492. HttpCliVersion = 708;
  493. CopyRight : String = ' THttpCli (c) 1997-2010 F. Piette V7.08 ';
  494. DefaultProxyPort = '80';
  495. HTTP_RCV_BUF_SIZE = 8193;
  496. HTTP_SND_BUF_SIZE = 8193;
  497. { EHttpException error code }
  498. httperrNoError = 0;
  499. httperrBusy = 1;
  500. httperrNoData = 2;
  501. httperrAborted = 3;
  502. httperrOverflow = 4;
  503. httperrVersion = 5;
  504. httperrInvalidAuthState = 6;
  505. httperrSslHandShake = 7;
  506. httperrCustomTimeOut = 8; { V7.04 }
  507. type
  508. THttpBigInt = Int64;
  509. EHttpException = class(Exception)
  510. ErrorCode : Word;
  511. constructor Create(const Msg : String; ErrCode : Word);
  512. end;
  513. // TBytes = array of Byte;
  514. THttpEncoding = (encUUEncode, encBase64, encMime);
  515. THttpRequest = (httpABORT, httpGET, httpPOST, httpPUT,
  516. httpHEAD, httpCLOSE);
  517. THttpState = (httpReady, httpNotConnected, httpConnected,
  518. httpDnsLookup, httpDnsLookupDone,
  519. httpWaitingHeader, httpWaitingBody, httpBodyReceived,
  520. httpWaitingProxyConnect,
  521. httpClosing, httpAborting);
  522. THttpChunkState = (httpChunkGetSize, httpChunkGetExt, httpChunkGetData,
  523. httpChunkSkipDataEnd, httpChunkDone);
  524. {$IFDEF UseNTLMAuthentication}
  525. THttpNTLMState = (ntlmNone, ntlmMsg1, ntlmMsg2, ntlmMsg3, ntlmDone);
  526. {$ENDIF}
  527. {$IFDEF UseDigestAuthentication}
  528. TAuthDigestInfo = TAuthDigestResponseInfo;
  529. THttpDigestState = (digestNone, digestMsg1, digestDone);
  530. {$ENDIF}
  531. THttpBasicState = (basicNone, basicMsg1, basicDone);
  532. THttpAuthType = (httpAuthNone, httpAuthBasic, httpAuthNtlm, httpAuthDigest);
  533. THttpBeforeAuthEvent = procedure(Sender : TObject;
  534. AuthType : THttpAuthType;
  535. ProxyAuth : Boolean;
  536. const AuthHdr : String;
  537. var Allow : Boolean) of object;
  538. TOnCommand = procedure (Sender : TObject;
  539. var S: String) of object;
  540. TDocDataEvent = procedure (Sender : TObject;
  541. {$IFDEF CLR}
  542. var Buffer : TBytes;
  543. Offset : Integer;
  544. {$ELSE}
  545. Buffer : Pointer;
  546. {$ENDIF}
  547. Len : Integer) of object;
  548. TCookieRcvdEvent = procedure (Sender : TObject;
  549. const Data : String;
  550. var Accept : Boolean) of object;
  551. THttpRequestDone = procedure (Sender : TObject;
  552. RqType : THttpRequest;
  553. ErrCode : Word) of object;
  554. TBeforeHeaderSendEvent = procedure (Sender : TObject;
  555. const Method : String;
  556. Headers : TStrings) of object;
  557. THttpCliOption = (httpoNoBasicAuth, httpoNoNTLMAuth, httpoBandwidthControl,
  558. {$IFDEF UseContentCoding}
  559. httpoEnableContentCoding, httpoUseQuality,
  560. {$ENDIF}
  561. httpoNoDigestAuth);
  562. THttpCliOptions = set of THttpCliOption;
  563. TLocationChangeExceeded = procedure (Sender : TObject;
  564. const RelocationCount : Integer;
  565. var AllowMoreRelocations : Boolean) of object; { V1.90 }
  566. THttpCli = class(TIcsWndControl)
  567. protected
  568. FMsg_WM_HTTP_REQUEST_DONE : UINT;
  569. FMsg_WM_HTTP_SET_READY : UINT;
  570. FMsg_WM_HTTP_LOGIN : UINT;
  571. FCtrlSocket : TWSocket;
  572. //FWindowHandle : HWND;
  573. FMultiThreaded : Boolean;
  574. FState : THttpState;
  575. FLocalAddr : String;
  576. FHostName : String;
  577. FTargetHost : String;
  578. FTargetPort : String;
  579. FPort : String;
  580. FProtocol : String;
  581. FProxy : String;
  582. FProxyPort : String;
  583. FUsername : String;
  584. FPassword : String;
  585. FCurrUsername : String;
  586. FCurrPassword : String;
  587. FProxyUsername : String;
  588. FProxyPassword : String;
  589. FProxyConnected : Boolean;
  590. FLocation : String;
  591. FCurrentHost : String;
  592. FCurrentPort : String;
  593. FCurrentProtocol : String;
  594. FConnected : Boolean;
  595. FDnsResult : String;
  596. // FSendBuffer : array [0..HTTP_SND_BUF_SIZE - 1] of char;
  597. FSendBuffer : TBytes; // FP 09/09/06
  598. FRequestType : THttpRequest;
  599. // FReceiveBuffer : array [0..HTTP_RCV_BUF_SIZE - 1] of char;
  600. FReceiveBuffer : TBytes; // FP 09/09/06
  601. FReceiveLen : Integer;
  602. FLastResponse : String;
  603. FHeaderLineCount : Integer;
  604. FBodyLineCount : Integer;
  605. FAllowedToSend : Boolean;
  606. FDelaySetReady : Boolean; { 09/26/08 ML }
  607. FURL : String;
  608. FPath : String;
  609. FDocName : String;
  610. FSender : String;
  611. FReference : String;
  612. FConnection : String; { for Keep-alive }
  613. FProxyConnection : String; { for proxy keep-alive }
  614. FCurrConnection : String;
  615. FCurrProxyConnection : String;
  616. FAgent : String;
  617. FAccept : String;
  618. FAcceptLanguage : String;
  619. FModifiedSince : TDateTime; { Warning ! Use GMT date/Time }
  620. FNoCache : Boolean;
  621. FStatusCode : Integer;
  622. FReasonPhrase : String;
  623. FResponseVer : String;
  624. FRequestVer : String;
  625. FContentLength : THttpBigInt;
  626. FContentType : String;
  627. FTransferEncoding : String;
  628. {$IFDEF UseContentCoding}
  629. FContentEncoding : String;
  630. FContentCodingHnd : THttpContCodHandler;
  631. FRcvdStreamStartSize : Integer;
  632. {$ENDIF}
  633. FChunkLength : Integer;
  634. FChunkRcvd : Integer;
  635. FChunkState : THttpChunkState;
  636. FDoAuthor : TStringList;
  637. FContentPost : String; { Also used for PUT }
  638. FContentRangeBegin : String;
  639. FContentRangeEnd : String;
  640. FAcceptRanges : String;
  641. FCookie : String;
  642. FLocationFlag : Boolean;
  643. FFollowRelocation : Boolean; {TED}
  644. FHeaderEndFlag : Boolean;
  645. FRcvdHeader : TStrings;
  646. FRcvdStream : TStream; { If assigned, will recv the answer }
  647. FRcvdCount : THttpBigInt; { Number of rcvd bytes for the body }
  648. FSentCount : THttpBigInt;
  649. FSendStream : TStream; { Contains the data to send }
  650. FReqStream : TMemoryStream;
  651. FRequestDoneError : Integer;
  652. FNext : procedure of object;
  653. // FBodyData : PChar;
  654. FBodyData : Integer; // Offset in FReceiveBuffer (FP 09/09/06)
  655. FBodyDataLen : THttpBigInt;
  656. FOptions : THttpCliOptions;
  657. FSocksServer : String;
  658. FSocksLevel : String;
  659. FSocksPort : String;
  660. FSocksUsercode : String;
  661. FSocksPassword : String;
  662. FSocksAuthentication : TSocksAuthentication;
  663. {$IFDEF UseNTLMAuthentication}
  664. FNTLMMsg2Info : TNTLM_Msg2_Info;
  665. FProxyNTLMMsg2Info : TNTLM_Msg2_Info;
  666. FAuthNTLMState : THttpNTLMState;
  667. FProxyAuthNTLMState : THttpNTLMState;
  668. {$ENDIF}
  669. {$IFDEF UseDigestAuthentication}
  670. FAuthDigestState : THttpDigestState;
  671. FProxyAuthDigestState : THttpDigestState;
  672. FAuthDigestInfo : TAuthDigestInfo;
  673. FAuthDigestProxyInfo : TAuthDigestInfo;
  674. { As specified in RFC 2617, section 3.2.2.4, used only with auth-int }
  675. FAuthDigestEntityHash : THashHex;
  676. {$ENDIF}
  677. FOnBeforeAuth : THttpBeforeAuthEvent;
  678. FAuthBasicState : THttpBasicState;
  679. FProxyAuthBasicState : THttpBasicState;
  680. //FServerAuth : String;
  681. //FProxyAuth : String;
  682. FServerAuth : THttpAuthType;
  683. FProxyAuth : THttpAuthType;
  684. {$IFDEF UseBandwidthControl}
  685. FBandwidthLimit : Integer; // Bytes per second
  686. FBandwidthSampling : Integer; // mS sampling interval
  687. FBandwidthCount : Int64; // Byte counter
  688. FBandwidthMaxCount : Int64; // Bytes during sampling period
  689. FBandwidthTimer : TIcsTimer;
  690. FBandwidthPaused : Boolean;
  691. FTimerOldEnabled : Boolean;
  692. {$ENDIF}
  693. FOnStateChange : TNotifyEvent;
  694. FOnSessionConnected : TNotifyEvent;
  695. FOnSessionClosed : TNotifyEvent;
  696. FOnRequestHeaderBegin : TNotifyEvent;
  697. FOnRequestHeaderEnd : TNotifyEvent;
  698. FOnHeaderBegin : TNotifyEvent;
  699. FOnHeaderEnd : TNotifyEvent;
  700. FOnHeaderData : TNotifyEvent;
  701. FOnDocBegin : TNotifyEvent;
  702. FOnDocEnd : TNotifyEvent;
  703. FOnDocData : TDocDataEvent;
  704. FOnSendBegin : TNotifyEvent;
  705. FOnSendEnd : TNotifyEvent;
  706. FOnSendData : TDocDataEvent;
  707. FOnTrace : TNotifyEvent;
  708. FOnCommand : TOnCommand;
  709. FOnCookie : TCookieRcvdEvent;
  710. FOnDataPush : TDataAvailable;
  711. FOnDataPush2 : TNotifyEvent;
  712. FOnRequestDone : THttpRequestDone;
  713. FOnLocationChange : TNotifyEvent;
  714. FLocationChangeMaxCount : Integer; { V1.90 }
  715. FLocationChangeCurCount : Integer; { V1.90 }
  716. FOnLocationChangeExceeded : TLocationChangeExceeded; { V1.90 }
  717. { Added by Eugene Mayevski }
  718. FOnSocksConnected : TSessionConnected;
  719. FOnSocksAuthState : TSocksAuthStateEvent;
  720. FOnSocksError : TSocksErrorEvent;
  721. FOnSocketError : TNotifyEvent;
  722. FOnBeforeHeaderSend : TBeforeHeaderSendEvent; { Wilfried 9 sep 02}
  723. FCloseReq : Boolean; { SAE 01/06/04 }
  724. FTimeout : UINT; { V7.04 } { Sync Timeout Seconds }
  725. procedure AllocateMsgHandlers; override;
  726. procedure FreeMsgHandlers; override;
  727. function MsgHandlersCount: Integer; override;
  728. procedure CheckDelaySetReady; { 09/26/08 ML }
  729. {$IFNDEF NO_DEBUG_LOG}
  730. function GetIcsLogger: TIcsLogger; { V1.91 }
  731. procedure SetIcsLogger(const Value: TIcsLogger); { V1.91 }
  732. procedure DebugLog(LogOption: TLogOption; const Msg : string); virtual; { V1.91 }
  733. function CheckLogOptions(const LogOption: TLogOption): Boolean; virtual; { V1.91 }
  734. {$ENDIF}
  735. {$IFDEF UseBandwidthControl}
  736. procedure BandwidthTimerTimer(Sender : TObject);
  737. {$ENDIF}
  738. procedure CreateSocket; virtual;
  739. procedure DoBeforeConnect; virtual;
  740. procedure DoSocksConnected(Sender: TObject; ErrCode: Word);
  741. procedure DoSocksAuthState(Sender : TObject; AuthState : TSocksAuthState);
  742. procedure DoSocksError(Sender : TObject; ErrCode : Integer; Msg : String);
  743. procedure SocketErrorTransfer(Sender : TObject);
  744. procedure SendRequest(const method, Version: String); virtual;
  745. procedure GetHeaderLineNext; virtual;
  746. procedure GetBodyLineNext; virtual;
  747. procedure SendCommand(const Cmd : String); virtual;
  748. procedure Login; virtual;
  749. procedure Logout; virtual;
  750. procedure InternalClear; virtual;
  751. procedure StartRelocation; virtual;
  752. {$IFDEF UseNTLMAuthentication}
  753. procedure StartAuthNTLM; virtual;
  754. procedure StartProxyAuthNTLM; virtual; {BLD proxy NTLM support }
  755. function GetNTLMMessage1(const ForProxy: Boolean) : String;
  756. function GetNTLMMessage3(const HttpMethod: String;
  757. const ForProxy: Boolean): String;
  758. procedure ElaborateNTLMAuth;
  759. function PrepareNTLMAuth(var FlgClean : Boolean) : Boolean;
  760. {$ENDIF}
  761. {$IFDEF UseDigestAuthentication}
  762. procedure ElaborateDigestAuth;
  763. function GetDigestAuthorizationHeader(const HttpMethod: String;
  764. ProxyAuth : Boolean): String;
  765. function PrepareDigestAuth(var FlgClean : Boolean) : Boolean;
  766. procedure StartAuthDigest; virtual;
  767. procedure StartProxyAuthDigest; virtual;
  768. {$ENDIF}
  769. function GetBasicAuthorizationHeader(
  770. const HttpMethod: String; ProxyAuth: Boolean): String;
  771. procedure CleanupRcvdStream;
  772. procedure CleanupSendStream;
  773. procedure StartAuthBasic; virtual;
  774. procedure StartProxyAuthBasic; virtual;
  775. procedure ElaborateBasicAuth;
  776. function PrepareBasicAuth(var FlgClean : Boolean) : Boolean;
  777. procedure SocketDNSLookupDone(Sender: TObject; ErrCode: Word); virtual;
  778. procedure SocketSessionClosed(Sender: TObject; ErrCode: Word); virtual;
  779. procedure SocketSessionConnected(Sender : TObject; ErrCode : Word); virtual;
  780. procedure SocketDataSent(Sender : TObject; ErrCode : Word); virtual;
  781. procedure SocketDataAvailable(Sender: TObject; ErrCode: Word); virtual;
  782. function StartsWithText(Source : TBytes; Find : PAnsiChar) : Boolean; {Bjornar}
  783. function ContainsText(Source : TBytes; Find : PAnsiChar) : Boolean; {Bjornar}
  784. procedure LocationSessionClosed(Sender: TObject; ErrCode: Word); virtual;
  785. procedure DoRequestAsync(Rq : THttpRequest); virtual;
  786. procedure DoRequestSync(Rq : THttpRequest); virtual;
  787. procedure SetMultiThreaded(newValue : Boolean); virtual;
  788. procedure StateChange(NewState : THttpState); virtual;
  789. procedure TriggerStateChange; virtual;
  790. procedure TriggerCookie(const Data : String;
  791. var bAccept : Boolean); virtual;
  792. procedure TriggerSessionConnected; virtual;
  793. procedure TriggerSessionClosed; virtual;
  794. procedure TriggerBeforeHeaderSend(const Method : String;
  795. Headers : TStrings); virtual;
  796. procedure TriggerRequestHeaderBegin; virtual;
  797. procedure TriggerRequestHeaderEnd; virtual;
  798. procedure TriggerHeaderBegin; virtual;
  799. procedure TriggerHeaderEnd; virtual;
  800. procedure TriggerDocBegin; virtual;
  801. procedure TriggerDocData(
  802. {$IFDEF CLR}
  803. var Data : TBytes;
  804. Offset : Integer;
  805. {$ELSE}
  806. Data : Pointer;
  807. {$ENDIF}
  808. Len : Integer); virtual;
  809. procedure TriggerDocEnd; virtual;
  810. procedure TriggerSendBegin; virtual;
  811. procedure TriggerSendData(
  812. {$IFDEF CLR}
  813. var Data : TBytes;
  814. Offset : Integer;
  815. {$ELSE}
  816. Data : Pointer;
  817. {$ENDIF}
  818. Len : Integer); virtual;
  819. procedure TriggerSendEnd; virtual;
  820. procedure TriggerRequestDone; virtual;
  821. procedure WndProc(var MsgRec: OverbyteIcsTypes.TMessage); override;
  822. procedure SetReady; virtual;
  823. procedure AdjustDocName; virtual;
  824. procedure SetRequestVer(const Ver : String);
  825. procedure WMHttpRequestDone(var msg: TMessage);
  826. procedure WMHttpSetReady(var msg: TMessage);
  827. procedure WMHttpLogin(var msg: TMessage);
  828. {$IFDEF UseContentCoding}
  829. function GetOptions: THttpCliOptions;
  830. procedure SetOptions(const Value : THttpCliOptions);
  831. {$ENDIF}
  832. {$IFDEF USE_SSL}
  833. procedure SslHandshakeDone(Sender : TObject;
  834. ErrCode : Word;
  835. PeerCert : TX509Base;
  836. var Disconnect : Boolean);
  837. {$ENDIF}
  838. public
  839. constructor Create(Aowner:TComponent); override;
  840. destructor Destroy; override;
  841. procedure Get; { Synchronous blocking Get }
  842. procedure Post; { Synchronous blocking Post }
  843. procedure Put; { Synchronous blocking Put }
  844. procedure Head; { Synchronous blocking Head }
  845. procedure Close; { Synchronous blocking Close }
  846. procedure Abort; { Synchrounous blocking Abort }
  847. procedure GetASync; { Asynchronous, non-blocking Get }
  848. procedure PostASync; { Asynchronous, non-blocking Post }
  849. procedure PutASync; { Asynchronous, non-blocking Put }
  850. procedure HeadASync; { Asynchronous, non-blocking Head }
  851. procedure CloseAsync; { Asynchronous, non-blocking Close }
  852. procedure ThreadAttach; override;
  853. procedure ThreadDetach; override;
  854. property CtrlSocket : TWSocket read FCtrlSocket;
  855. //property Handle : HWND read FWindowHandle;
  856. property State : THttpState read FState;
  857. property LastResponse : String read FLastResponse;
  858. property ContentLength : THttpBigInt read FContentLength;
  859. property ContentType : String read FContentType;
  860. property TransferEncoding : String read FTransferEncoding;
  861. {$IFDEF UseContentCoding}
  862. property ContentEncoding : String read FContentEncoding;
  863. property ContentCodingHnd : THttpContCodHandler read FContentCodingHnd;
  864. {$ENDIF}
  865. property RcvdCount : THttpBigInt read FRcvdCount;
  866. property SentCount : THttpBigInt read FSentCount;
  867. property StatusCode : Integer read FStatusCode;
  868. property ReasonPhrase : String read FReasonPhrase;
  869. property DnsResult : String read FDnsResult;
  870. property AuthorizationRequest : TStringList read FDoAuthor;
  871. property DocName : String read FDocName;
  872. property Location : String read FLocation
  873. write FLocation;
  874. property RcvdStream : TStream read FRcvdStream
  875. write FRcvdStream;
  876. property SendStream : TStream read FSendStream
  877. write FSendStream;
  878. property RcvdHeader : TStrings read FRcvdHeader;
  879. property Hostname : String read FHostname;
  880. property Protocol : String read FProtocol;
  881. {$IFDEF UseDigestAuthentication}
  882. property AuthDigestInfo : TAuthDigestInfo
  883. read FAuthDigestInfo
  884. write FAuthDigestInfo;
  885. property AuthDigestProxyInfo : TAuthDige