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

Function validate_hdr_host

src/proxy/hdrs/HTTP.cc:1210–1243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1208}
1209
1210ParseResult
1211validate_hdr_host(HTTPHdrImpl *hh)
1212{
1213 ParseResult ret = PARSE_RESULT_DONE;
1214 MIMEField *host_field = mime_hdr_field_find(hh->m_fields_impl, MIME_FIELD_HOST, MIME_LEN_HOST);
1215 if (host_field) {
1216 if (host_field->has_dups()) {
1217 ret = PARSE_RESULT_ERROR; // can't have more than 1 host field.
1218 } else {
1219 auto host{host_field->value_get()};
1220 std::string_view addr, port, rest;
1221 if (0 == ats_ip_parse(host, &addr, &port, &rest)) {
1222 if (!port.empty()) {
1223 if (port.size() > 5) {
1224 return PARSE_RESULT_ERROR;
1225 }
1226 int port_i = ink_atoi(port.data(), port.size());
1227 if (port_i >= 65536 || port_i <= 0) {
1228 return PARSE_RESULT_ERROR;
1229 }
1230 }
1231 if (!validate_host_name(addr)) {
1232 return PARSE_RESULT_ERROR;
1233 }
1234 if (PARSE_RESULT_DONE == ret && !std::all_of(rest.begin(), rest.end(), &ParseRules::is_ws)) {
1235 return PARSE_RESULT_ERROR;
1236 }
1237 } else {
1238 ret = PARSE_RESULT_ERROR;
1239 }
1240 }
1241 }
1242 return ret;
1243}
1244
1245ParseResult
1246validate_hdr_content_length(HdrHeap *heap, HTTPHdrImpl *hh)

Callers 1

http_parser_parse_reqFunction · 0.85

Calls 11

mime_hdr_field_findFunction · 0.85
ats_ip_parseFunction · 0.85
ink_atoiFunction · 0.85
validate_host_nameFunction · 0.85
has_dupsMethod · 0.80
value_getMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected