nghttpx: Use StringRef for AltSvc fields
This commit is contained in:
parent
fdc1eb526b
commit
c4368a9416
|
@ -2376,16 +2376,16 @@ int parse_config(Config *config, int optid, const StringRef &opt,
|
||||||
|
|
||||||
AltSvc altsvc{};
|
AltSvc altsvc{};
|
||||||
|
|
||||||
altsvc.protocol_id = tokens[0].str();
|
altsvc.protocol_id = make_string_ref(config->balloc, tokens[0]);
|
||||||
|
|
||||||
altsvc.port = port;
|
altsvc.port = port;
|
||||||
altsvc.service = tokens[1].str();
|
altsvc.service = make_string_ref(config->balloc, tokens[1]);
|
||||||
|
|
||||||
if (tokens.size() > 2) {
|
if (tokens.size() > 2) {
|
||||||
altsvc.host = tokens[2].str();
|
altsvc.host = make_string_ref(config->balloc, tokens[2]);
|
||||||
|
|
||||||
if (tokens.size() > 3) {
|
if (tokens.size() > 3) {
|
||||||
altsvc.origin = tokens[3].str();
|
altsvc.origin = make_string_ref(config->balloc, tokens[3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,7 @@ enum shrpx_forwarded_node_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AltSvc {
|
struct AltSvc {
|
||||||
std::string protocol_id, host, origin, service;
|
StringRef protocol_id, host, origin, service;
|
||||||
|
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
};
|
};
|
||||||
|
|
|
@ -962,10 +962,9 @@ std::unique_ptr<Downstream> HttpsUpstream::pop_downstream() {
|
||||||
namespace {
|
namespace {
|
||||||
void write_altsvc(DefaultMemchunks *buf, BlockAllocator &balloc,
|
void write_altsvc(DefaultMemchunks *buf, BlockAllocator &balloc,
|
||||||
const AltSvc &altsvc) {
|
const AltSvc &altsvc) {
|
||||||
buf->append(
|
buf->append(util::percent_encode_token(balloc, altsvc.protocol_id));
|
||||||
util::percent_encode_token(balloc, StringRef{altsvc.protocol_id}));
|
|
||||||
buf->append("=\"");
|
buf->append("=\"");
|
||||||
buf->append(util::quote_string(balloc, StringRef{altsvc.host}));
|
buf->append(util::quote_string(balloc, altsvc.host));
|
||||||
buf->append(':');
|
buf->append(':');
|
||||||
buf->append(altsvc.service);
|
buf->append(altsvc.service);
|
||||||
buf->append('"');
|
buf->append('"');
|
||||||
|
|
Loading…
Reference in New Issue