MCPcopy Create free account
hub / github.com/apache/trafficserver / http_parse_qvalue

Function http_parse_qvalue

src/proxy/hdrs/HTTP.cc:1599–1664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1597 -------------------------------------------------------------------------*/
1598
1599static double
1600http_parse_qvalue(const char *&buf, int &len)
1601{
1602 double val = 1.0;
1603
1604 if (*buf != ';') {
1605 return val;
1606 }
1607
1608 buf += 1;
1609 len -= 1;
1610
1611 while (len > 0 && *buf) {
1612 http_skip_ws(buf, len);
1613
1614 if (*buf == 'q') {
1615 buf += 1;
1616 len -= 1;
1617 http_skip_ws(buf, len);
1618
1619 if (*buf == '=') {
1620 double n;
1621 int f;
1622
1623 buf += 1;
1624 len -= 1;
1625 http_skip_ws(buf, len);
1626
1627 n = 0.0;
1628 while (len > 0 && *buf && isdigit(*buf)) {
1629 n = (n * 10) + (*buf++ - '0');
1630 len -= 1;
1631 }
1632
1633 if (*buf == '.') {
1634 buf += 1;
1635 len -= 1;
1636
1637 f = 10;
1638 while (len > 0 && *buf && isdigit(*buf)) {
1639 n += (*buf++ - '0') / static_cast<double>(f);
1640 f *= 10;
1641 len -= 1;
1642 }
1643 }
1644
1645 val = n;
1646 }
1647 } else {
1648 // The current parameter is not a q-value, so go to the next param.
1649 while (len > 0 && *buf) {
1650 if (*buf != ';') {
1651 buf += 1;
1652 len -= 1;
1653 } else {
1654 // Move to the character after the semicolon.
1655 buf += 1;
1656 len -= 1;

Callers 1

http_parse_teFunction · 0.85

Calls 1

http_skip_wsFunction · 0.85

Tested by

no test coverage detected