Struct http_stub::header::Upgrade [] [src]

pub struct Upgrade(pub Vec<Protocol>);

Upgrade header, defined in RFC7230

The Upgrade header field is intended to provide a simple mechanism for transitioning from HTTP/1.1 to some other protocol on the same connection. A client MAY send a list of protocols in the Upgrade header field of a request to invite the server to switch to one or more of those protocols, in order of descending preference, before sending the final response. A server MAY ignore a received Upgrade header field if it wishes to continue using the current protocol on that connection. Upgrade cannot be used to insist on a protocol change.

ABNF

Upgrade          = 1#protocol

protocol         = protocol-name ["/" protocol-version]
protocol-name    = token
protocol-version = token

Example values

Examples

use hyper::header::{Headers, Upgrade, Protocol, ProtocolName};

let mut headers = Headers::new();
headers.set(Upgrade(vec![Protocol::new(ProtocolName::WebSocket, None)]));
use hyper::header::{Headers, Upgrade, Protocol, ProtocolName};

let mut headers = Headers::new();
headers.set(
    Upgrade(vec![
        Protocol::new(ProtocolName::Http, Some("2.0".to_owned())),
        Protocol::new(ProtocolName::Unregistered("SHTTP".to_owned()),
            Some("1.3".to_owned())),
        Protocol::new(ProtocolName::Unregistered("IRC".to_owned()),
            Some("6.9".to_owned())),
    ])
);