src: Don't process rel=preload again once we found it
This commit is contained in:
parent
2d6211c455
commit
10ec00126c
84
src/http2.cc
84
src/http2.cc
|
@ -924,53 +924,55 @@ parse_next_link_header_once(const char *first, const char *last) {
|
||||||
// we expect link-param
|
// we expect link-param
|
||||||
|
|
||||||
if (!ign) {
|
if (!ign) {
|
||||||
// rel can take several relations using quoted form.
|
if (!ok) {
|
||||||
static constexpr char PLP[] = "rel=\"";
|
// rel can take several relations using quoted form.
|
||||||
static constexpr size_t PLPLEN = str_size(PLP);
|
static constexpr char PLP[] = "rel=\"";
|
||||||
|
static constexpr size_t PLPLEN = str_size(PLP);
|
||||||
|
|
||||||
static constexpr char PLT[] = "preload";
|
static constexpr char PLT[] = "preload";
|
||||||
static constexpr size_t PLTLEN = str_size(PLT);
|
static constexpr size_t PLTLEN = str_size(PLT);
|
||||||
if (first + PLPLEN < last && *(first + PLPLEN - 1) == '"' &&
|
if (first + PLPLEN < last && *(first + PLPLEN - 1) == '"' &&
|
||||||
std::equal(PLP, PLP + PLPLEN, first, util::CaseCmp())) {
|
std::equal(PLP, PLP + PLPLEN, first, util::CaseCmp())) {
|
||||||
// we have to search preload in whitespace separated list:
|
// we have to search preload in whitespace separated list:
|
||||||
// rel="preload something http://example.org/foo"
|
// rel="preload something http://example.org/foo"
|
||||||
first += PLPLEN;
|
first += PLPLEN;
|
||||||
auto start = first;
|
auto start = first;
|
||||||
for (; first != last;) {
|
for (; first != last;) {
|
||||||
if (*first != ' ' && *first != '"') {
|
if (*first != ' ' && *first != '"') {
|
||||||
++first;
|
++first;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start == first) {
|
||||||
|
return {{StringRef{}}, last};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ok && start + PLTLEN == first &&
|
||||||
|
std::equal(PLT, PLT + PLTLEN, start, util::CaseCmp())) {
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*first == '"') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
first = skip_lws(first, last);
|
||||||
|
start = first;
|
||||||
}
|
}
|
||||||
|
if (first == last) {
|
||||||
if (start == first) {
|
|
||||||
return {{StringRef{}}, last};
|
return {{StringRef{}}, last};
|
||||||
}
|
}
|
||||||
|
assert(*first == '"');
|
||||||
if (!ok && start + PLTLEN == first &&
|
|
||||||
std::equal(PLT, PLT + PLTLEN, start, util::CaseCmp())) {
|
|
||||||
ok = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*first == '"') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
first = skip_lws(first, last);
|
|
||||||
start = first;
|
|
||||||
}
|
|
||||||
if (first == last) {
|
|
||||||
return {{StringRef{}}, first};
|
|
||||||
}
|
|
||||||
assert(*first == '"');
|
|
||||||
++first;
|
|
||||||
if (first == last || *first == ',') {
|
|
||||||
goto almost_done;
|
|
||||||
}
|
|
||||||
if (*first == ';') {
|
|
||||||
++first;
|
++first;
|
||||||
// parse next link-param
|
if (first == last || *first == ',') {
|
||||||
continue;
|
goto almost_done;
|
||||||
|
}
|
||||||
|
if (*first == ';') {
|
||||||
|
++first;
|
||||||
|
// parse next link-param
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return {{StringRef{}}, last};
|
||||||
}
|
}
|
||||||
return {{StringRef{}}, last};
|
|
||||||
}
|
}
|
||||||
// we are only interested in rel=preload parameter. Others are
|
// we are only interested in rel=preload parameter. Others are
|
||||||
// simply skipped.
|
// simply skipped.
|
||||||
|
|
Loading…
Reference in New Issue