CFHTTPStream.pas 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. {
  2. File: CFNetwork/CFHTTPStream.h
  3. Contains: CoreFoundation Network HTTP streams header
  4. Version: CFNetwork-71.2~1
  5. Copyright: © 2001-2003 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://www.freepascal.org/bugs.html
  9. }
  10. { Pascal Translation: Peter N Lewis, <[email protected]>, 2004 }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit CFHTTPStream;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,CFStream,CFBase,CFHTTPMessage;
  92. {$ALIGN MAC68K}
  93. {
  94. * kCFStreamErrorDomainHTTP
  95. *
  96. * Availability:
  97. * Mac OS X: in version 10.1 and later in CoreServices.framework
  98. * CarbonLib: not available
  99. * Non-Carbon CFM: not available
  100. }
  101. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  102. var kCFStreamErrorDomainHTTP: SInt32; external name '_kCFStreamErrorDomainHTTP'; (* attribute const *)
  103. type
  104. CFStreamErrorHTTP = SInt32;
  105. const
  106. kCFStreamErrorHTTPParseFailure = -1;
  107. kCFStreamErrorHTTPRedirectionLoop = -2;
  108. kCFStreamErrorHTTPBadURL = -3;
  109. { Value is a CFHTTPMessage with 0 bytes data. }
  110. {
  111. * kCFStreamPropertyHTTPResponseHeader
  112. *
  113. * Availability:
  114. * Mac OS X: in version 10.1 and later in CoreServices.framework
  115. * CarbonLib: not available
  116. * Non-Carbon CFM: not available
  117. }
  118. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  119. var kCFStreamPropertyHTTPResponseHeader: CFStringRef; external name '_kCFStreamPropertyHTTPResponseHeader'; (* attribute const *)
  120. { Value is the CFURL from the final request; will only differ from the URL in the original request if an autoredirection has occurred. }
  121. {
  122. * kCFStreamPropertyHTTPFinalURL
  123. *
  124. * Availability:
  125. * Mac OS X: in version 10.2 and later in CoreServices.framework
  126. * CarbonLib: not available
  127. * Non-Carbon CFM: not available
  128. }
  129. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  130. var kCFStreamPropertyHTTPFinalURL: CFStringRef; external name '_kCFStreamPropertyHTTPFinalURL'; (* attribute const *)
  131. {************************************}
  132. {Set-able properties on HTTP streams }
  133. {************************************}
  134. { HTTP proxy information is set the same way as SOCKS proxies (see CFSocketStream.h).
  135. Call CFReadStreamSetProperty() passing an HTTP stream and the property kCFStreamPropertyHTTPProxy.
  136. The value should be a CFDictionary that includes at least one Host/Port pair from the keys below.
  137. The dictionary returned by SystemConfiguration.framework can also be passed directly as the value }
  138. {
  139. * kCFStreamPropertyHTTPProxy
  140. *
  141. * Availability:
  142. * Mac OS X: in version 10.2 and later in CoreServices.framework
  143. * CarbonLib: not available
  144. * Non-Carbon CFM: not available
  145. }
  146. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  147. var kCFStreamPropertyHTTPProxy: CFStringRef; external name '_kCFStreamPropertyHTTPProxy'; (* attribute const *)
  148. {
  149. * kCFStreamPropertyHTTPProxyHost
  150. *
  151. * Availability:
  152. * Mac OS X: in version 10.2 and later in CoreServices.framework
  153. * CarbonLib: not available
  154. * Non-Carbon CFM: not available
  155. }
  156. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  157. var kCFStreamPropertyHTTPProxyHost: CFStringRef; external name '_kCFStreamPropertyHTTPProxyHost'; (* attribute const *)
  158. { matches kSCPropNetProxiesHTTPProxy; value should be a CFString}
  159. {
  160. * kCFStreamPropertyHTTPProxyPort
  161. *
  162. * Availability:
  163. * Mac OS X: in version 10.2 and later in CoreServices.framework
  164. * CarbonLib: not available
  165. * Non-Carbon CFM: not available
  166. }
  167. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  168. var kCFStreamPropertyHTTPProxyPort: CFStringRef; external name '_kCFStreamPropertyHTTPProxyPort'; (* attribute const *)
  169. { matches kSCPropNetProxiesHTTPPort; value should be a CFNumber }
  170. {
  171. * kCFStreamPropertyHTTPSProxyHost
  172. *
  173. * Availability:
  174. * Mac OS X: in version 10.2 and later in CoreServices.framework
  175. * CarbonLib: not available
  176. * Non-Carbon CFM: not available
  177. }
  178. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  179. var kCFStreamPropertyHTTPSProxyHost: CFStringRef; external name '_kCFStreamPropertyHTTPSProxyHost'; (* attribute const *)
  180. { matches kSCPropNetProxiesHTTPSProxy; value should be a CFString }
  181. {
  182. * kCFStreamPropertyHTTPSProxyPort
  183. *
  184. * Availability:
  185. * Mac OS X: in version 10.2 and later in CoreServices.framework
  186. * CarbonLib: not available
  187. * Non-Carbon CFM: not available
  188. }
  189. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  190. var kCFStreamPropertyHTTPSProxyPort: CFStringRef; external name '_kCFStreamPropertyHTTPSProxyPort'; (* attribute const *)
  191. { matches kSCPropNetProxiesHTTPSPort; value should be a CFNumber }
  192. { Value should be a CFBoolean }
  193. {
  194. * kCFStreamPropertyHTTPShouldAutoredirect
  195. *
  196. * Availability:
  197. * Mac OS X: in version 10.2 and later in CoreServices.framework
  198. * CarbonLib: not available
  199. * Non-Carbon CFM: not available
  200. }
  201. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  202. var kCFStreamPropertyHTTPShouldAutoredirect: CFStringRef; external name '_kCFStreamPropertyHTTPShouldAutoredirect'; (* attribute const *)
  203. { Value should be a CFBoolean. If this property is set to true, an HTTP stream will look for an appropriate extant persistent connection to use, and if it finds none, will try to create one. }
  204. {
  205. * kCFStreamPropertyHTTPAttemptPersistentConnection
  206. *
  207. * Availability:
  208. * Mac OS X: in version 10.2 and later in CoreServices.framework
  209. * CarbonLib: not available
  210. * Non-Carbon CFM: not available
  211. }
  212. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  213. var kCFStreamPropertyHTTPAttemptPersistentConnection: CFStringRef; external name '_kCFStreamPropertyHTTPAttemptPersistentConnection'; (* attribute const *)
  214. { Value is a CFNumber; this property can only be retrieved, not set. The number returned is the number of bytes from the body of the request that have been written to the underlying socket }
  215. {
  216. * kCFStreamPropertyHTTPRequestBytesWrittenCount
  217. *
  218. * Availability:
  219. * Mac OS X: in version 10.3 and later in CoreServices.framework
  220. * CarbonLib: not available
  221. * Non-Carbon CFM: not available
  222. }
  223. // AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
  224. var kCFStreamPropertyHTTPRequestBytesWrittenCount: CFStringRef; external name '_kCFStreamPropertyHTTPRequestBytesWrittenCount'; (* attribute const *)
  225. {*******************}
  226. { Creation routines }
  227. {*******************}
  228. { Creates a read stream for the response to the given request; when the stream is opened,
  229. it will begin transmitting the request. The bytes returned are the pure body bytes; the response header has been parsed off.
  230. To retrieve the response header, ask for kCFStreamPropertyHTTPResponseHeader, above, any time after the first bytes arrive on
  231. the stream (or when stream end is reported, if there are no data bytes).
  232. }
  233. {
  234. * CFReadStreamCreateForHTTPRequest()
  235. *
  236. * Availability:
  237. * Mac OS X: in version 10.1 and later in CoreServices.framework
  238. * CarbonLib: not available
  239. * Non-Carbon CFM: not available
  240. }
  241. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  242. function CFReadStreamCreateForHTTPRequest( alloc: CFAllocatorRef; request: CFHTTPMessageRef ): CFReadStreamRef; external name '_CFReadStreamCreateForHTTPRequest';
  243. { Creates a read stream for the response to the given requestHeaders plus requestBody. Use in preference to
  244. CFReadStreamCreateForHTTPRequest() when the body of the request is larger than you wish to be resident in memory. Note that
  245. because streams cannot be reset, read streams created this way cannot have autoredirection enabled. If the Content-Length
  246. header is set in requestHeaders, it is assumed that the caller got the length right and that requestBody will report
  247. end-of-stream after precisely Content-Length bytes have been read from it. If the Content-Length header is not set, the
  248. chunked transfer-encoding will be added to requestHeaders, and bytes read from requestBody will be transmitted chunked.
  249. The body of requestHeaders is ignored.
  250. }
  251. {
  252. * CFReadStreamCreateForStreamedHTTPRequest()
  253. *
  254. * Availability:
  255. * Mac OS X: in version 10.2 and later in CoreServices.framework
  256. * CarbonLib: not available
  257. * Non-Carbon CFM: not available
  258. }
  259. // AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER
  260. function CFReadStreamCreateForStreamedHTTPRequest( alloc: CFAllocatorRef; requestHeaders: CFHTTPMessageRef; requestBody: CFReadStreamRef ): CFReadStreamRef; external name '_CFReadStreamCreateForStreamedHTTPRequest';
  261. { Deprecated - Use the properties kCFStreamPropertyHTTPShouldAutoredirect and kCFStreamPropertyHTTPProxy above instead }
  262. {
  263. * CFHTTPReadStreamSetRedirectsAutomatically()
  264. *
  265. * Availability:
  266. * Mac OS X: in version 10.1 and later in CoreServices.framework
  267. * CarbonLib: not available
  268. * Non-Carbon CFM: not available
  269. }
  270. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  271. procedure CFHTTPReadStreamSetRedirectsAutomatically( httpStream: CFReadStreamRef; shouldAutoRedirect: Boolean ); external name '_CFHTTPReadStreamSetRedirectsAutomatically';
  272. {
  273. * CFHTTPReadStreamSetProxy()
  274. *
  275. * Availability:
  276. * Mac OS X: in version 10.1 and later in CoreServices.framework
  277. * CarbonLib: not available
  278. * Non-Carbon CFM: not available
  279. }
  280. // AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
  281. procedure CFHTTPReadStreamSetProxy( httpStream: CFReadStreamRef; proxyHost: CFStringRef; proxyPort: CFIndex ); external name '_CFHTTPReadStreamSetProxy';
  282. end.