Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  expect.rs

  Sprache: Rust
 

use std::fmt;

use util::IterExt;

/// The `Expect` header.
///
/// > The "Expect" header field in a request indicates a certain set of
/// > behaviors (expectations) that need to be supported by the server in
/// > order to properly handle this request.  The only such expectation
/// > defined by this specification is 100-continue.
/// >
/// >    Expect  = "100-continue"
///
/// # Example
///
/// ```
/// # extern crate headers;
/// use headers::Expect;
///
/// let expect = Expect::CONTINUE;
/// ```
#[derive(Clone, PartialEq)]
pub struct Expect(());

impl Expect {
    /// "100-continue"
    pub const CONTINUE: Expect = Expect(());
}

impl ::Header for Expect {
    fn name() -> &'static ::HeaderName {
        &::http::header::EXPECT
    }

    fn decode<'i, I: Iterator<Item = &'i ::HeaderValue>>(values: &mut I) -> Result<Self, ::Error> {
        values
            .just_one()
            .and_then(|value| {
                if value == "100-continue" {
                    Some(Expect::CONTINUE)
                } else {
                    None
                }
            })
            .ok_or_else(::Error::invalid)
    }

    fn encode<E: Extend<::HeaderValue>>(&self, values: &mut E) {
        values.extend(::std::iter::once(::HeaderValue::from_static(
            "100-continue",
        )));
    }
}

impl fmt::Debug for Expect {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_tuple("Expect").field(&"100-continue").finish()
    }
}

#[cfg(test)]
mod tests {
    use super::super::test_decode;
    use super::Expect;

    #[test]
    fn expect_continue() {
        assert_eq!(
            test_decode::<Expect>(&["100-continue"]),
            Some(Expect::CONTINUE),
        );
    }

    #[test]
    fn expectation_failed() {
        assert_eq!(test_decode::<Expect>(&["sandwich"]), None,);
    }

    #[test]
    fn too_many_values() {
        assert_eq!(
            test_decode::<Expect>(&["100-continue""100-continue"]),
            None,
        );
    }
}

Messung V0.5 in Prozent
C=82 H=100 G=91

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-19) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik