MCPcopy Create free account
hub / github.com/MrKepzie/Natron / http_parse_host

Function http_parse_host

libs/qhttpserver/http-parser/http_parser.c:2233–2304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2231}
2232
2233static int
2234http_parse_host(const char * buf, struct http_parser_url *u, int found_at) {
2235 enum http_host_state s;
2236
2237 const char *p;
2238 size_t buflen = u->field_data[UF_HOST].off + u->field_data[UF_HOST].len;
2239
2240 u->field_data[UF_HOST].len = 0;
2241
2242 s = found_at ? s_http_userinfo_start : s_http_host_start;
2243
2244 for (p = buf + u->field_data[UF_HOST].off; p < buf + buflen; p++) {
2245 enum http_host_state new_s = http_parse_host_char(s, *p);
2246
2247 if (new_s == s_http_host_dead) {
2248 return 1;
2249 }
2250
2251 switch(new_s) {
2252 case s_http_host:
2253 if (s != s_http_host) {
2254 u->field_data[UF_HOST].off = p - buf;
2255 }
2256 u->field_data[UF_HOST].len++;
2257 break;
2258
2259 case s_http_host_v6:
2260 if (s != s_http_host_v6) {
2261 u->field_data[UF_HOST].off = p - buf;
2262 }
2263 u->field_data[UF_HOST].len++;
2264 break;
2265
2266 case s_http_host_port:
2267 if (s != s_http_host_port) {
2268 u->field_data[UF_PORT].off = p - buf;
2269 u->field_data[UF_PORT].len = 0;
2270 u->field_set |= (1 << UF_PORT);
2271 }
2272 u->field_data[UF_PORT].len++;
2273 break;
2274
2275 case s_http_userinfo:
2276 if (s != s_http_userinfo) {
2277 u->field_data[UF_USERINFO].off = p - buf ;
2278 u->field_data[UF_USERINFO].len = 0;
2279 u->field_set |= (1 << UF_USERINFO);
2280 }
2281 u->field_data[UF_USERINFO].len++;
2282 break;
2283
2284 default:
2285 break;
2286 }
2287 s = new_s;
2288 }
2289
2290 /* 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