Skip to content

body size #2712

@silence-coding

Description

@silence-coding

If a request without a body does not carry content-length or chunk, the size_hint method of the body can obtain the correct value in the HTTP1 scenario but cannot obtain the correct value in the H2 scenario.

    fn size_hint(&self) -> SizeHint {
        match self.kind {
            Kind::Once(Some(ref val)) => SizeHint::with_exact(val.len() as u64),
  //HTTP1
            Kind::Once(None) => SizeHint::with_exact(0), 
            #[cfg(feature = "stream")]
            Kind::Wrapped(..) => SizeHint::default(),
//HTTP2
            Kind::Chan { content_length, .. } | Kind::H2 { content_length, .. } => {
                let mut hint = SizeHint::default();

                if let Some(content_length) = content_length.into_opt() {
                    hint.set_exact(content_length);
                }

                hint
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug. Something is wrong. This is bad!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions