http_connection.inc 6.4 KB

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