http_connection.inc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. { Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. }
  16. {
  17. * @package Apache connection library
  18. }
  19. {#include "apr_hooks.h"
  20. #include "apr_network_io.h"
  21. #include "apr_buckets.h"}
  22. {
  23. * @file http_connection.h
  24. * @brief Apache connection library
  25. }
  26. //#ifdef CORE_PRIVATE
  27. {
  28. * This is the protocol module driver. This calls all of the
  29. * pre-connection and connection hooks for all protocol modules.
  30. * @param c The connection on which the request is read
  31. * @param csd The mechanism on which this connection is to be read.
  32. * Most times this will be a socket, but it is up to the module
  33. * that accepts the request to determine the exact type.
  34. * @deffunc void ap_process_connection(conn_rec *c, void *csd)
  35. }
  36. procedure ap_process_connection(c: Pconn_rec; csd: Pointer);
  37. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  38. external LibHTTPD name LibNamePrefix + 'ap_process_connection' + LibSuff8;
  39. {
  40. * Flushes all remain data in the client send buffer
  41. * @param c The connection to flush
  42. }
  43. procedure ap_flush_conn(c: Pconn_rec);
  44. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  45. external LibHTTPD name LibNamePrefix + 'ap_flush_conn' + LibSuff4;
  46. {
  47. * This function is responsible for the following cases:
  48. * <pre>
  49. * we now proceed to read from the client until we get EOF, or until
  50. * MAX_SECS_TO_LINGER has passed. the reasons for doing this are
  51. * documented in a draft:
  52. *
  53. * http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-connection-00.txt
  54. *
  55. * in a nutshell -- if we don't make this effort we risk causing
  56. * TCP RST packets to be sent which can tear down a connection before
  57. * all the response data has been sent to the client.
  58. * </pre>
  59. * @param c The connection we are closing
  60. }
  61. procedure ap_lingering_close(c: Pconn_rec);
  62. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  63. external LibHTTPD name LibNamePrefix + 'ap_lingering_close' + LibSuff4;
  64. //#endif COREPRIVATE
  65. { Hooks }
  66. {
  67. * create_connection is a RUN_FIRST hook which allows modules to create
  68. * connections. In general, you should not install filters with the
  69. * create_connection hook. If you require vhost configuration information
  70. * to make filter installation decisions, you must use the pre_connection
  71. * or install_network_transport hook. This hook should close the connection
  72. * if it encounters a fatal error condition.
  73. *
  74. * @param p The pool from which to allocate the connection record
  75. * @param csd The socket that has been accepted
  76. * @param conn_id A unique identifier for this connection. The ID only
  77. * needs to be unique at that time, not forever.
  78. * @param sbh A handle to scoreboard information for this connection.
  79. * @return An allocated connection record or NULL.
  80. }
  81. type
  82. ap_HOOK_create_connection_t = function (p: Papr_pool_t; server: Pserver_rec;
  83. csd: Papr_socket_t; conn_id: cLong; sbh: Pointer;
  84. alloc: Papr_bucket_alloc_t): Pconn_rec; cdecl;
  85. procedure ap_hook_create_connection(pf: ap_HOOK_create_connection_t; const aszPre: PPChar;
  86. const aszSucc: PPChar; nOrder: Integer);
  87. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  88. external LibHTTPD name LibNamePrefix + 'ap_hook_create_connection' + LibSuff16;
  89. {
  90. * This hook gives protocol modules an opportunity to set everything up
  91. * before calling the protocol handler. All pre-connection hooks are
  92. * run until one returns something other than ok or decline
  93. * @param c The connection on which the request has been received.
  94. * @param csd The mechanism on which this connection is to be read.
  95. * Most times this will be a socket, but it is up to the module
  96. * that accepts the request to determine the exact type.
  97. * @return OK or DECLINED
  98. * @deffunc int ap_run_pre_connection(conn_rec *c, void *csd)
  99. }
  100. type
  101. ap_HOOK_pre_connection_t = function (c: Pconn_rec; csd: Pointer): Integer; cdecl;
  102. procedure ap_hook_pre_connection(pf: ap_HOOK_pre_connection_t; const aszPre: PPChar;
  103. const aszSucc: PPChar; nOrder: Integer);
  104. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  105. external LibHTTPD name LibNamePrefix + 'ap_hook_pre_connection' + LibSuff16;
  106. {
  107. * This hook implements different protocols. After a connection has been
  108. * established, the protocol module must read and serve the request. This
  109. * function does that for each protocol module. The first protocol module
  110. * to handle the request is the last module run.
  111. * @param c The connection on which the request has been received.
  112. * @return OK or DECLINED
  113. * @deffunc int ap_run_process_connection(conn_rec *c)
  114. }
  115. type
  116. ap_HOOK_process_connection_t = function (c: Pconn_rec): Integer; cdecl;
  117. procedure ap_hook_process_connection(pf: ap_HOOK_process_connection_t; const aszPre: PPChar;
  118. const aszSucc: PPChar; nOrder: Integer);
  119. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  120. external LibHTTPD name LibNamePrefix + 'ap_hook_process_connection' + LibSuff16;
  121. { End Of Connection (EOC) bucket }
  122. //AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eoc;
  123. {
  124. * Determine if a bucket is an End Of Connection (EOC) bucket
  125. * @param e The bucket to inspect
  126. * @return true or false
  127. }
  128. //#define AP_BUCKET_IS_EOC(e) (e->type == &ap_bucket_type_eoc)
  129. {
  130. * Make the bucket passed in an End Of Connection (EOC) bucket
  131. * @param b The bucket to make into an EOC bucket
  132. * @return The new bucket, or NULL if allocation failed
  133. * @deffunc apr_bucket *ap_bucket_eoc_make(apr_bucket *b)
  134. }
  135. function ap_bucket_eoc_make(b: Papr_bucket): Papr_bucket;
  136. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  137. external LibHTTPD name LibNamePrefix + 'ap_bucket_eoc_make' + LibSuff4;
  138. {
  139. * Create a bucket referring to an End Of Connection (EOC). This indicates
  140. * that the connection will be closed.
  141. * @param list The freelist from which this bucket should be allocated
  142. * @return The new bucket, or NULL if allocation failed
  143. * @deffunc apr_bucket *ap_bucket_eoc_create(apr_bucket_alloc_t *list)
  144. }
  145. function ap_bucket_eoc_create(list: Papr_bucket_alloc_t): Papr_bucket;
  146. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  147. external LibHTTPD name LibNamePrefix + 'ap_bucket_eoc_create' + LibSuff4;