httpheaderhttpver.c (1195B)
1 /************************************************************************* 2 * This file is part of Crosroads 1.23, a load balancer and fail over 3 * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. 4 * Visit http://crossroads.e-tunity.com for information. 5 *************************************************************************/ 6 #include "crossroads.h" 7 8 double http_header_httpver (HttpHeader *h) { 9 double ret; 10 11 /* We need at least a header line */ 12 if (h->nheader < 1) { 13 warning ("Service %s: cannot get HTTP version, no headers", 14 activeservice->name); 15 return (0.9); 16 } 17 18 /* We need HTTP/1.? length */ 19 if (strlen (h->header[0]) < 8) { 20 warning ("Service %s: cannot get HTTP version, header line '%s'", 21 activeservice->name, h->header[0]); 22 return (0.9); 23 } 24 25 /* If the line starts with HTTP then it's a server line. 26 * Otherwise it's a client line. */ 27 if (!strncmp (h->header[0], "HTTP/", 5)) 28 ret = atof (h->header[0] + 5); 29 else 30 ret = atof (h->header[0] + strlen(h->header[0]) - 3); 31 32 msg ("Service %s: HTTP version is %g (headerline %s)", 33 activeservice->name, ret, h->header[0]); 34 return (ret); 35 } 36