MCPcopy Create free account
hub / github.com/apache/httpd / protocol_cmp

Function protocol_cmp

server/protocol.c:2377–2395  ·  view source on GitHub ↗

* Compare two protocol identifier. Result is similar to strcmp(): * 0 gives same precedence, >0 means proto1 is preferred. */

Source from the content-addressed store, hash-verified

2375 * 0 gives same precedence, >0 means proto1 is preferred.
2376 */
2377static int protocol_cmp(const apr_array_header_t *preferences,
2378 const char *proto1,
2379 const char *proto2)
2380{
2381 if (preferences && preferences->nelts > 0) {
2382 int index1 = ap_array_str_index(preferences, proto1, 0);
2383 int index2 = ap_array_str_index(preferences, proto2, 0);
2384 if (index2 > index1) {
2385 return (index1 >= 0) ? 1 : -1;
2386 }
2387 else if (index1 > index2) {
2388 return (index2 >= 0) ? -1 : 1;
2389 }
2390 }
2391 /* both have the same index (maybe -1 or no pref configured) and we compare
2392 * the names so that spdy3 gets precedence over spdy2. That makes
2393 * the outcome at least deterministic. */
2394 return strcmp(proto1, proto2);
2395}
2396
2397AP_DECLARE(const char *) ap_get_protocol(conn_rec *c)
2398{

Callers 1

ap_select_protocolFunction · 0.85

Calls 1

ap_array_str_indexFunction · 0.85

Tested by

no test coverage detected