Skip to content

Commit dc02e7f

Browse files
DavidSchinazicopybara-github
authored andcommitted
Add new prober for Chunked OHTTP
This CL intentionally makes this prober use IPv4 so that between the regular "success" prober and this one we get coverage of both IP version. This CL also fixes a bug in the handling of the use_client_cert_for_key_fetch option. This CL also fixes a bug in the test client that was causing the private token not to be properly sent for chunked requests. PiperOrigin-RevId: 865419113
1 parent 5519a76 commit dc02e7f

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

quiche/quic/masque/masque_ohttp_client.cc

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,22 +331,14 @@ absl::Status MasqueOhttpClient::SendOhttpRequest(
331331
control_data.scheme = url.scheme();
332332
control_data.authority = url.HostPort();
333333
control_data.path = url.PathParamsQuery();
334-
BinaryHttpRequest binary_request(control_data);
335-
binary_request.set_body(post_data);
334+
std::string encrypted_data;
335+
PendingRequest pending_request(per_request_config);
336+
std::string formatted_token;
336337
if (!per_request_config.private_token().empty()) {
337338
QUICHE_ASSIGN_OR_RETURN(
338-
std::string formatted_token,
339+
formatted_token,
339340
FormatPrivateToken(per_request_config.private_token()));
340-
binary_request.AddHeaderField({"authorization", formatted_token});
341341
}
342-
absl::StatusOr<std::string> encoded_request = binary_request.Serialize();
343-
if (!encoded_request.ok()) {
344-
return absl::InternalError(
345-
absl::StrCat("Failed to serialize OHTTP request: ",
346-
encoded_request.status().message()));
347-
}
348-
std::string encrypted_data;
349-
PendingRequest pending_request(per_request_config);
350342
if (!ohttp_client_.has_value()) {
351343
QUICHE_LOG(FATAL) << "Cannot send OHTTP request without OHTTP client";
352344
return absl::InternalError(
@@ -369,6 +361,9 @@ absl::Status MasqueOhttpClient::SendOhttpRequest(
369361
QUICHE_ASSIGN_OR_RETURN(std::string encoded_data,
370362
encoder.EncodeControlData(control_data));
371363
std::vector<quiche::BinaryHttpMessage::FieldView> headers;
364+
if (!formatted_token.empty()) {
365+
headers.push_back({"authorization", formatted_token});
366+
}
372367
QUICHE_ASSIGN_OR_RETURN(std::string encoded_headers,
373368
encoder.EncodeHeaders(absl::MakeSpan(headers)));
374369
encoded_data += encoded_headers;
@@ -412,6 +407,17 @@ absl::Status MasqueOhttpClient::SendOhttpRequest(
412407

413408
pending_request.chunk_handler->SetChunkedClient(std::move(*chunked_client));
414409
} else {
410+
BinaryHttpRequest binary_request(control_data);
411+
binary_request.set_body(post_data);
412+
if (!formatted_token.empty()) {
413+
binary_request.AddHeaderField({"authorization", formatted_token});
414+
}
415+
absl::StatusOr<std::string> encoded_request = binary_request.Serialize();
416+
if (!encoded_request.ok()) {
417+
return absl::InternalError(
418+
absl::StrCat("Failed to serialize OHTTP request: ",
419+
encoded_request.status().message()));
420+
}
415421
absl::StatusOr<ObliviousHttpRequest> ohttp_request =
416422
ohttp_client_->CreateObliviousHttpRequest(*encoded_request);
417423
if (!ohttp_request.ok()) {

0 commit comments

Comments
 (0)