mirror of
https://github.com/apache/httpd.git
synced 2025-08-07 04:02:58 +03:00
adding ap_get_protocol(c) which safeguards against NULL returns, for use instead of direct calling ap_run_protocol_get
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1697855 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -723,8 +723,8 @@ AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r))
|
||||
* @param c The current connection
|
||||
* @param r The current request or NULL
|
||||
* @param s The server/virtual host selected
|
||||
* @param offers a list of protocol identifiers offered by the client
|
||||
* @param proposals the list of protocol identifiers proposed by the hooks
|
||||
* @param offers A list of protocol identifiers offered by the client
|
||||
* @param proposals The list of protocol identifiers proposed by the hooks
|
||||
* @return OK or DECLINED
|
||||
*/
|
||||
AP_DECLARE_HOOK(int,protocol_propose,(conn_rec *c, request_rec *r,
|
||||
@@ -752,7 +752,7 @@ AP_DECLARE_HOOK(int,protocol_propose,(conn_rec *c, request_rec *r,
|
||||
* @param c The current connection
|
||||
* @param r The current request or NULL
|
||||
* @param s The server/virtual host selected
|
||||
* @param choices a list of protocol identifiers, normally the clients whishes
|
||||
* @param choices A list of protocol identifiers, normally the clients whishes
|
||||
* @param proposals the list of protocol identifiers proposed by the hooks
|
||||
* @return OK or DECLINED
|
||||
*/
|
||||
@@ -765,8 +765,11 @@ AP_DECLARE_HOOK(int,protocol_switch,(conn_rec *c, request_rec *r,
|
||||
* protocol switching must register here and return the correct protocol
|
||||
* identifier for connections they switched.
|
||||
*
|
||||
* To find out the protocol for the current connection, better call
|
||||
* @see ap_get_protocol which internally uses this hook.
|
||||
*
|
||||
* @param c The current connection
|
||||
* @return The identifier of the protocol in place
|
||||
* @return The identifier of the protocol in place or NULL
|
||||
*/
|
||||
AP_DECLARE_HOOK(const char *,protocol_get,(const conn_rec *c))
|
||||
|
||||
@@ -778,8 +781,8 @@ AP_DECLARE_HOOK(const char *,protocol_get,(const conn_rec *c))
|
||||
* @param c The current connection
|
||||
* @param r The current request or NULL
|
||||
* @param s The server/virtual host selected
|
||||
* @param choices a list of protocol identifiers, normally the clients whishes
|
||||
* @return the selected protocol
|
||||
* @param choices A list of protocol identifiers, normally the clients whishes
|
||||
* @return The selected protocol
|
||||
*/
|
||||
AP_DECLARE(const char *) ap_select_protocol(conn_rec *c, request_rec *r,
|
||||
server_rec *s,
|
||||
@@ -803,6 +806,19 @@ AP_DECLARE(apr_status_t) ap_switch_protocol(conn_rec *c, request_rec *r,
|
||||
server_rec *s,
|
||||
const char *protocol);
|
||||
|
||||
/**
|
||||
* Call the protocol_get hook to determine the protocol currently in use
|
||||
* for the given connection.
|
||||
*
|
||||
* Unless another protocol has been switch to, will default to
|
||||
* @see AP_PROTOCOL_HTTP1 and modules implementing a new protocol must
|
||||
* report a switched connection via the protocol_get hook.
|
||||
*
|
||||
* @param c The connection to determine the protocol for
|
||||
* @return the protocol in use, never NULL
|
||||
*/
|
||||
AP_DECLARE(const char *) ap_get_protocol(conn_rec *c);
|
||||
|
||||
/** @see ap_bucket_type_error */
|
||||
typedef struct ap_bucket_error ap_bucket_error;
|
||||
|
||||
|
@@ -161,7 +161,7 @@ int h2_h2_process_conn(conn_rec* c)
|
||||
* -> sniff for the magic PRIamble. On TLS, this might trigger the ALPN.
|
||||
*/
|
||||
if (!h2_ctx_protocol_get(c)
|
||||
&& !strcmp(AP_PROTOCOL_HTTP1, ap_run_protocol_get(c))) {
|
||||
&& !strcmp(AP_PROTOCOL_HTTP1, ap_get_protocol(c))) {
|
||||
apr_status_t status;
|
||||
|
||||
temp = apr_brigade_create(c->pool, c->bucket_alloc);
|
||||
@@ -170,7 +170,7 @@ int h2_h2_process_conn(conn_rec* c)
|
||||
|
||||
if (status == APR_SUCCESS) {
|
||||
if (h2_ctx_protocol_get(c)
|
||||
|| strcmp(AP_PROTOCOL_HTTP1, ap_run_protocol_get(c))) {
|
||||
|| strcmp(AP_PROTOCOL_HTTP1, ap_get_protocol(c))) {
|
||||
/* h2 or another protocol has been selected. */
|
||||
}
|
||||
else {
|
||||
|
@@ -65,7 +65,7 @@ static int h2_protocol_propose(conn_rec *c, request_rec *r,
|
||||
int proposed = 0;
|
||||
const char **protos = h2_h2_is_tls(c)? h2_tls_protos : h2_clear_protos;
|
||||
|
||||
if (strcmp(AP_PROTOCOL_HTTP1, ap_run_protocol_get(c))) {
|
||||
if (strcmp(AP_PROTOCOL_HTTP1, ap_get_protocol(c))) {
|
||||
/* We do not know how to switch from anything else but http/1.1.
|
||||
*/
|
||||
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c,
|
||||
|
@@ -1505,7 +1505,7 @@ static apr_status_t ssl_io_filter_input(ap_filter_t *f,
|
||||
APLOGNO(02836) "ALPN selected protocol: '%s'",
|
||||
protocol);
|
||||
|
||||
if (strcmp(protocol, ap_run_protocol_get(f->c))) {
|
||||
if (strcmp(protocol, ap_get_protocol(f->c))) {
|
||||
status = ap_switch_protocol(f->c, NULL, sslconn->server,
|
||||
protocol);
|
||||
if (status != APR_SUCCESS) {
|
||||
|
@@ -5282,11 +5282,6 @@ static void core_dump_config(apr_pool_t *p, server_rec *s)
|
||||
}
|
||||
}
|
||||
|
||||
static const char *core_protocol_get(const conn_rec *c)
|
||||
{
|
||||
return AP_PROTOCOL_HTTP1;
|
||||
}
|
||||
|
||||
static int core_upgrade_handler(request_rec *r)
|
||||
{
|
||||
conn_rec *c = r->connection;
|
||||
@@ -5308,7 +5303,7 @@ static int core_upgrade_handler(request_rec *r)
|
||||
if (offers && offers->nelts > 0) {
|
||||
const char *protocol = ap_select_protocol(c, r, r->server,
|
||||
offers);
|
||||
if (strcmp(protocol, ap_run_protocol_get(c))) {
|
||||
if (strcmp(protocol, ap_get_protocol(c))) {
|
||||
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02909)
|
||||
"Upgrade selects '%s'", protocol);
|
||||
/* Let the client know what we are upgrading to. */
|
||||
@@ -5385,7 +5380,6 @@ static void register_hooks(apr_pool_t *p)
|
||||
ap_hook_open_htaccess(ap_open_htaccess, NULL, NULL, APR_HOOK_REALLY_LAST);
|
||||
ap_hook_optional_fn_retrieve(core_optional_fn_retrieve, NULL, NULL,
|
||||
APR_HOOK_MIDDLE);
|
||||
ap_hook_protocol_get(core_protocol_get, NULL, NULL, APR_HOOK_REALLY_LAST);
|
||||
|
||||
/* register the core's insert_filter hook and register core-provided
|
||||
* filters
|
||||
|
@@ -1971,13 +1971,19 @@ static int protocol_cmp(apr_array_header_t *preferences,
|
||||
return strcmp(proto1, proto2);
|
||||
}
|
||||
|
||||
AP_DECLARE(const char *) ap_get_protocol(conn_rec *c)
|
||||
{
|
||||
const char *protocol = ap_run_protocol_get(c);
|
||||
return protocol? protocol : AP_PROTOCOL_HTTP1;
|
||||
}
|
||||
|
||||
AP_DECLARE(const char *) ap_select_protocol(conn_rec *c, request_rec *r,
|
||||
server_rec *s,
|
||||
apr_array_header_t *choices)
|
||||
{
|
||||
apr_pool_t *pool = r? r->pool : c->pool;
|
||||
apr_array_header_t *proposals;
|
||||
const char *protocol = NULL, *existing = ap_run_protocol_get(c);
|
||||
const char *protocol = NULL, *existing = ap_get_protocol(c);
|
||||
core_server_config *conf = ap_get_core_module_config(s->module_config);
|
||||
|
||||
if (APLOGcdebug(c)) {
|
||||
@@ -2038,7 +2044,7 @@ AP_DECLARE(apr_status_t) ap_switch_protocol(conn_rec *c, request_rec *r,
|
||||
server_rec *s,
|
||||
const char *protocol)
|
||||
{
|
||||
const char *current = ap_run_protocol_get(c);
|
||||
const char *current = ap_get_protocol(c);
|
||||
int rc;
|
||||
|
||||
if (!strcmp(current, protocol)) {
|
||||
|
Reference in New Issue
Block a user