MCPcopy Create free account
hub / github.com/apache/brpc / http_parse_host

Function http_parse_host

src/brpc/details/http_parser.cpp:2269–2340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2267}
2268
2269static int
2270http_parse_host(const char * buf, struct http_parser_url *u, int found_at) {
2271 enum http_host_state s;
2272
2273 const char *p;
2274 size_t buflen = u->field_data[UF_HOST].off + u->field_data[UF_HOST].len;
2275
2276 u->field_data[UF_HOST].len = 0;
2277
2278 s = found_at ? s_http_userinfo_start : s_http_host_start;
2279
2280 for (p = buf + u->field_data[UF_HOST].off; p < buf + buflen; p++) {
2281 enum http_host_state new_s = http_parse_host_char(s, *p);
2282
2283 if (new_s == s_http_host_dead) {
2284 return 1;
2285 }
2286
2287 switch(new_s) {
2288 case s_http_host:
2289 if (s != s_http_host) {
2290 u->field_data[UF_HOST].off = p - buf;
2291 }
2292 u->field_data[UF_HOST].len++;
2293 break;
2294
2295 case s_http_host_v6:
2296 if (s != s_http_host_v6) {
2297 u->field_data[UF_HOST].off = p - buf;
2298 }
2299 u->field_data[UF_HOST].len++;
2300 break;
2301
2302 case s_http_host_port:
2303 if (s != s_http_host_port) {
2304 u->field_data[UF_PORT].off = p - buf;
2305 u->field_data[UF_PORT].len = 0;
2306 u->field_set |= (1 << UF_PORT);
2307 }
2308 u->field_data[UF_PORT].len++;
2309 break;
2310
2311 case s_http_userinfo:
2312 if (s != s_http_userinfo) {
2313 u->field_data[UF_USERINFO].off = p - buf ;
2314 u->field_data[UF_USERINFO].len = 0;
2315 u->field_set |= (1 << UF_USERINFO);
2316 }
2317 u->field_data[UF_USERINFO].len++;
2318 break;
2319
2320 default:
2321 break;
2322 }
2323 s = new_s;
2324 }
2325
2326 /* Make sure we don't end somewhere unexpected */

Callers 1

http_parser_parse_urlFunction · 0.85

Calls 1

http_parse_host_charFunction · 0.85

Tested by

no test coverage detected