Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill downstream_client_request_id in #282

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions lib/src/wiggle_abi/req_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,33 @@ impl FastlyHttpReq for Session {
}
}

#[allow(unused_variables)] // FIXME FGS 2023-06-14: Remove this directive once implemented.
fn downstream_client_request_id(
&mut self,
reqid_out: &GuestPtr<u8>,
reqid_max_len: u32,
nwritten_out: &GuestPtr<u32>,
) -> Result<(), Error> {
nwritten_out.write(0)?;
let reqid_bytes = format!("{:032x}", self.req_id()).into_bytes();

if reqid_bytes.len() > reqid_max_len as usize {
// Write out the number of bytes necessary to fit the value, or zero on overflow to
// signal an error condition.
nwritten_out.write(reqid_bytes.len().try_into().unwrap_or(0))?;
return Err(Error::BufferLengthError {
buf: "reqid_out",
len: "reqid_max_len",
});
}

let reqid_len =
u32::try_from(reqid_bytes.len()).expect("smaller u32::MAX means it must fit");

let mut reqid_slice = reqid_out
.as_array(reqid_len)
.as_slice_mut()?
.ok_or(Error::SharedMemory)?;
reqid_slice.copy_from_slice(&reqid_bytes);
nwritten_out.write(reqid_len)?;
Ok(())
}

Expand Down