summaryrefslogtreecommitdiffstats
path: root/third_party/rust/glean/src/net
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /third_party/rust/glean/src/net
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/glean/src/net')
-rw-r--r--third_party/rust/glean/src/net/http_uploader.rs11
-rw-r--r--third_party/rust/glean/src/net/mod.rs25
2 files changed, 27 insertions, 9 deletions
diff --git a/third_party/rust/glean/src/net/http_uploader.rs b/third_party/rust/glean/src/net/http_uploader.rs
index 4646fe61b4..4ca1687acf 100644
--- a/third_party/rust/glean/src/net/http_uploader.rs
+++ b/third_party/rust/glean/src/net/http_uploader.rs
@@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-use crate::net::{PingUploader, UploadResult};
+use crate::net::{PingUploadRequest, PingUploader, UploadResult};
/// A simple mechanism to upload pings over HTTPS.
#[derive(Debug)]
@@ -13,12 +13,9 @@ impl PingUploader for HttpUploader {
///
/// # Arguments
///
- /// * `url` - the URL path to upload the data to.
- /// * `body` - the serialized text data to send.
- /// * `headers` - a vector of tuples containing the headers to send with
- /// the request, i.e. (Name, Value).
- fn upload(&self, url: String, _body: Vec<u8>, _headers: Vec<(String, String)>) -> UploadResult {
- log::debug!("TODO bug 1675468: submitting to {:?}", url);
+ /// * `upload_request` - the requested upload.
+ fn upload(&self, upload_request: PingUploadRequest) -> UploadResult {
+ log::debug!("TODO bug 1675468: submitting to {:?}", upload_request.url);
UploadResult::http_status(200)
}
}
diff --git a/third_party/rust/glean/src/net/mod.rs b/third_party/rust/glean/src/net/mod.rs
index 5571d30e67..5546078e63 100644
--- a/third_party/rust/glean/src/net/mod.rs
+++ b/third_party/rust/glean/src/net/mod.rs
@@ -19,6 +19,20 @@ use thread_state::{AtomicState, State};
mod http_uploader;
+/// Everything you need to request a ping to be uploaded.
+pub struct PingUploadRequest {
+ /// The URL the Glean SDK expects you to use to upload the ping.
+ pub url: String,
+ /// The body, already content-encoded, for upload.
+ pub body: Vec<u8>,
+ /// The HTTP headers, including any Content-Encoding.
+ pub headers: Vec<(String, String)>,
+ /// Whether the body has {client|ping}_info sections in it.
+ pub body_has_info_sections: bool,
+ /// The name (aka doctype) of the ping.
+ pub ping_name: String,
+}
+
/// A description of a component used to upload pings.
pub trait PingUploader: std::fmt::Debug + Send + Sync {
/// Uploads a ping to a server.
@@ -29,7 +43,7 @@ pub trait PingUploader: std::fmt::Debug + Send + Sync {
/// * `body` - the serialized text data to send.
/// * `headers` - a vector of tuples containing the headers to send with
/// the request, i.e. (Name, Value).
- fn upload(&self, url: String, body: Vec<u8>, headers: Vec<(String, String)>) -> UploadResult;
+ fn upload(&self, upload_request: PingUploadRequest) -> UploadResult;
}
/// The logic for uploading pings: this leaves the actual upload mechanism as
@@ -105,7 +119,14 @@ impl UploadManager {
let upload_url = format!("{}{}", inner.server_endpoint, request.path);
let headers: Vec<(String, String)> =
request.headers.into_iter().collect();
- let result = inner.uploader.upload(upload_url, request.body, headers);
+ let upload_request = PingUploadRequest {
+ url: upload_url,
+ body: request.body,
+ headers,
+ body_has_info_sections: request.body_has_info_sections,
+ ping_name: request.ping_name,
+ };
+ let result = inner.uploader.upload(upload_request);
// Process the upload response.
match glean_core::glean_process_ping_upload_response(doc_id, result) {
UploadTaskAction::Next => (),