Skip to main content

UploadRequest

Struct UploadRequest 

Source
pub struct UploadRequest<'a> {
    pub target: Target<'a>,
    pub method: UploadMethod,
    pub body: UploadBody,
    pub priority: Priority,
    pub max_response: u64,
    pub headers: &'a [(String, String)],
    pub basic_auth: Option<&'a BasicAuth>,
    pub bearer_token: Option<&'a BearerToken>,
    pub allow_cleartext_credentials: bool,
    pub response_timeout: Option<Duration>,
}
Expand description

The request of one upload, which sends a body and gets a bounded response.

The Debug output shows the name of each header, and <redacted> in place of its value. The target shows as the Debug output of Target shows it.

Fields§

§target: Target<'a>

The target, read as FetchRequest::target is. A Target::PathQuery goes to the mirrors with its query, as for a fetch.

The fetcher tries the mirrors in order until one of them takes the request. It never asks a mirror after that one.

§method: UploadMethod

The method.

The default is POST.

§body: UploadBody

The body that the request sends.

§priority: Priority

The place of the request in the queue when the fetcher is at its limit.

§max_response: u64

The largest response body, in bytes, for each status.

A larger Content-Length of a 2xx answer fails the upload with Error::UploadInterrupted. An answer other than 2xx with a larger Content-Length keeps its status, and its body is withheld. If a body grows past the cap while it streams, the read fails with io::ErrorKind::FileTooLarge. The default is UploadRequest::DEFAULT_MAX_RESPONSE.

§headers: &'a [(String, String)]

Headers merged over the headers of the fetcher.

FetchRequest::headers states the merge. The fetcher sets no Content-Type, so a Content-Type that the server needs goes here.

§basic_auth: Option<&'a BasicAuth>

Credentials for Authorization: Basic, for this request.

They replace the credentials of the fetcher.

Beside bearer_token, beside an Authorization entry in headers, or beside a signer of the fetcher, they fail the upload before admission with Error::Fetch.

§bearer_token: Option<&'a BearerToken>

A token for Authorization: Bearer, for this request.

It replaces the credentials of the fetcher.

Beside basic_auth, beside an Authorization entry in headers, or beside a signer of the fetcher, it fails the upload before admission with Error::Fetch.

§allow_cleartext_credentials: bool

The permission for a credential to reach a cleartext origin.

FetchRequest::allow_cleartext_credentials states the rule.

§response_timeout: Option<Duration>

The longest wait for the response head after hyper takes the end of the body.

None takes progress_timeout.

Implementations§

Source§

impl<'a> UploadRequest<'a>

Source

pub const DEFAULT_MAX_RESPONSE: u64

The default response cap of a request: 2 MiB.

Source

pub fn path(path: &'a str, body: UploadBody) -> UploadRequest<'a>

Creates a POST of body to path under each mirror.

The request has normal priority. It carries the headers and the credentials of the fetcher.

Source

pub fn url(url: &'a str, body: UploadBody) -> UploadRequest<'a>

Creates a POST of body to the absolute URL url.

The request has normal priority. It carries the headers and the credentials of the fetcher.

Trait Implementations§

Source§

impl Debug for UploadRequest<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for UploadRequest<'a>

§

impl<'a> Forget for UploadRequest<'a>

§

impl<'a> Move for UploadRequest<'a>

§

impl<'a> RefUnwindSafe for UploadRequest<'a>

§

impl<'a> Send for UploadRequest<'a>
where &'a str: Send, Bytes: Send, Arc<Exchange>: Send, &'a [(String, String)]: Send, &'a BasicAuth: Send, &'a BearerToken: Send,

§

impl<'a> Sync for UploadRequest<'a>
where Bytes: Sync, Arc<Exchange>: Sync, RawVecInner: Sync,

§

impl<'a> Unpin for UploadRequest<'a>
where &'a str: Unpin, *const u8: Unpin, Align8<*mut ()>: Unpin, &'static Vtable: Unpin, Arc<Exchange>: Unpin, &'a [(String, String)]: Unpin, &'a BasicAuth: Unpin, &'a BearerToken: Unpin,

§

impl<'a> UnsafeUnpin for UploadRequest<'a>
where &'a str: UnsafeUnpin, *const u8: UnsafeUnpin, Align8<*mut ()>: UnsafeUnpin, &'static Vtable: UnsafeUnpin, *const ArcInner<Exchange> is !null: UnsafeUnpin, PhantomData<ArcInner<Exchange>>: UnsafeUnpin, &'a [(String, String)]: UnsafeUnpin, &'a BasicAuth: UnsafeUnpin, &'a BearerToken: UnsafeUnpin,

§

impl<'a> UnwindSafe for UploadRequest<'a>
where &'a str: UnwindSafe, *const u8: UnwindSafe, Align8<*mut ()>: UnwindSafe, &'static Vtable: UnwindSafe, Arc<Exchange>: UnwindSafe, &'a [(String, String)]: UnwindSafe, &'a BasicAuth: UnwindSafe, &'a BearerToken: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more