mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Report URI with POST fetch request (#37209)
Part of #4577 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
parent
1b5a10a55f
commit
63cfeb3a18
22 changed files with 277 additions and 119 deletions
|
@ -9,6 +9,7 @@ use content_security_policy::{self as csp};
|
|||
use http::header::{AUTHORIZATION, HeaderName};
|
||||
use http::{HeaderMap, Method};
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender, IpcSharedMemory};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use mime::Mime;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -925,3 +926,22 @@ pub fn convert_header_names_to_sorted_lowercase_set(
|
|||
ordered_set.dedup();
|
||||
ordered_set.into_iter().cloned().collect()
|
||||
}
|
||||
|
||||
pub fn create_request_body_with_content(content: &str) -> RequestBody {
|
||||
let content_bytes = IpcSharedMemory::from_bytes(content.as_bytes());
|
||||
let content_len = content_bytes.len();
|
||||
|
||||
let (chunk_request_sender, chunk_request_receiver) = ipc::channel().unwrap();
|
||||
ROUTER.add_typed_route(
|
||||
chunk_request_receiver,
|
||||
Box::new(move |message| {
|
||||
let request = message.unwrap();
|
||||
if let BodyChunkRequest::Connect(sender) = request {
|
||||
let _ = sender.send(BodyChunkResponse::Chunk(content_bytes.clone()));
|
||||
let _ = sender.send(BodyChunkResponse::Done);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
RequestBody::new(chunk_request_sender, BodySource::Object, Some(content_len))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue