Struct qiniu_http::Request

source ·
pub struct Request<'r, B: 'r> { /* private fields */ }
Expand description

HTTP 请求

封装 HTTP 请求相关字段

Implementations§

创建 HTTP 请求构建器

获取请求体

获取请求体的可变引用

Examples found in repository?
src/request.rs (line 494)
493
494
495
496
    pub fn body(&mut self, body: B) -> &mut Self {
        *self.inner.body_mut() = body;
        self
    }

转换为 HTTP 请求体

获取请求信息

获取请求信息的可变引用

转换为请求信息和请求体

通过请求信息和请求体创建 HTTP 请求

Methods from Deref<Target = RequestParts<'r>>§

获取 HTTP 请求 URL

获取 HTTP 请求 URL 的可变引用

Examples found in repository?
src/request.rs (line 459)
458
459
460
461
    pub fn url(&mut self, url: Uri) -> &mut Self {
        *self.inner.url_mut() = url;
        self
    }

获取请求 HTTP 版本

获取请求 HTTP 版本的可变引用

Examples found in repository?
src/request.rs (line 473)
472
473
474
475
    pub fn version(&mut self, version: Version) -> &mut Self {
        *self.inner.version_mut() = version;
        self
    }

获取请求 HTTP 方法

获取请求 HTTP 方法的可变引用

Examples found in repository?
src/request.rs (line 466)
465
466
467
468
    pub fn method(&mut self, method: Method) -> &mut Self {
        *self.inner.method_mut() = method;
        self
    }

获取请求 HTTP Headers

获取请求 HTTP Headers 的可变引用

Examples found in repository?
src/request.rs (line 480)
479
480
481
482
483
484
485
486
487
488
489
    pub fn headers(&mut self, headers: HeaderMap) -> &mut Self {
        *self.inner.headers_mut() = headers;
        self
    }

    /// 插入请求 HTTP Header
    #[inline]
    pub fn header(&mut self, header_name: impl IntoHeaderName, header_value: impl Into<HeaderValue>) -> &mut Self {
        self.inner.headers_mut().insert(header_name, header_value.into());
        self
    }

获取扩展信息

获取扩展信息的可变引用

Examples found in repository?
src/request.rs (line 501)
500
501
502
503
504
505
506
507
508
509
510
    pub fn extensions(&mut self, extensions: Extensions) -> &mut Self {
        *self.inner.extensions_mut() = extensions;
        self
    }

    /// 追加扩展信息
    #[inline]
    pub fn add_extension<T: Sync + Send + 'static>(&mut self, val: T) -> &mut Self {
        self.inner.extensions_mut().insert(val);
        self
    }

获取 UserAgent

获取追加的 UserAgent

Examples found in repository?
src/request.rs (line 132)
127
128
129
130
131
132
133
134
    pub fn user_agent(&self) -> UserAgent {
        let mut user_agent = UserAgent::from(FULL_USER_AGENT.as_ref());
        if let Some(lib_user_agent) = LIBRARY_USER_AGENT.get() {
            user_agent.push_str(lib_user_agent);
        }
        user_agent.push_str(self.appended_user_agent().as_str());
        user_agent
    }

获取追加的 UserAgent 的可变引用

Examples found in repository?
src/request.rs (line 515)
514
515
516
517
    pub fn appended_user_agent(&mut self, user_agent: impl Into<UserAgent>) -> &mut Self {
        *self.inner.appended_user_agent_mut() = user_agent.into();
        self
    }

获取预解析的服务器套接字地址

获取预解析的服务器套接字地址的可变引用

Examples found in repository?
src/request.rs (line 522)
521
522
523
524
    pub fn resolved_ip_addrs(&mut self, resolved_ip_addrs: impl Into<Cow<'r, [IpAddr]>>) -> &mut Self {
        *self.inner.resolved_ip_addrs_mut() = Some(resolved_ip_addrs.into());
        self
    }

获取上传进度回调

获取上传进度回调的可变引用

Examples found in repository?
src/request.rs (line 529)
528
529
530
531
    pub fn on_uploading_progress(&mut self, f: impl Into<OnProgressCallback<'r>>) -> &mut Self {
        *self.inner.on_uploading_progress_mut() = Some(f.into());
        self
    }

获取接受到响应状态回调

获取接受到响应状态回调的可变引用

Examples found in repository?
src/request.rs (line 536)
535
536
537
538
    pub fn on_receive_response_status(&mut self, f: impl Into<OnStatusCodeCallback<'r>>) -> &mut Self {
        *self.inner.on_receive_response_status_mut() = Some(f.into());
        self
    }

获取接受到响应 Header 回调

获取接受到响应 Header 回调的可变引用

Examples found in repository?
src/request.rs (line 543)
542
543
544
545
    pub fn on_receive_response_header(&mut self, f: impl Into<OnHeaderCallback<'r>>) -> &mut Self {
        *self.inner.on_receive_response_header_mut() = Some(f.into());
        self
    }

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.