Skip to content

panicked at 'called Result::unwrap() on an Err value: Http(Response { status: 403, version: HTTP/1.1, headers: {"content-length": "9"}, body: Some([70, 111, 114, 98, 105, 100, 100, 101, 110]) })', #4

@lucasjinreal

Description

@lucasjinreal
panicked at 'called `Result::unwrap()` on an `Err` value: Http(Response { status: 403, version: HTTP/1.1, headers: {"content-length": "9"}, body: Some([70, 111, 114, 98, 105, 100, 100, 101, 110]) })',

貌似最新的rust版本,不这么指定回报header错误,制定了也会报错:

/// 多个时连接时返回所有 之后单个返回
    pub async fn quotes_ws(symbols: &str, handler: impl Fn(Vec<Quote>)) {
        let req = Request::builder()
            .method(Method::GET)
            .uri(format!(
                "wss://hq.sinajs.cn/wskt?list={}",
                fmt_quote_symbols(symbols)
            ))
            .header(header::ORIGIN, HeaderValue::from_static(PORTAL))
            .header(header::CONNECTION, "Upgrade")
            .header(header::UPGRADE, "websocket")
            .header("Sec-WebSocket-Version", "13")
            .header(header::HOST, HeaderValue::from_static(PORTAL))
            .header("Sec-WebSocket-Key", tungstenite::handshake::client::generate_key())
            .body(())
            .unwrap();

Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions