Boost logo

Boost :

Subject: Re: [boost] [Beast] Questions Before Review
From: Artyom Beilis (artyom.beilis_at_[hidden])
Date: 2017-07-01 19:27:03


http vs WebSocket
--------------------------

I noticed some strange difference in these requests :

 // Wrap the now-connected socket in a websocket stream
    websocket::stream<tcp::socket&> ws{sock};

    // Perform the websocket handhskae
    ws.handshake(host, "/", ec);
    if(ec)
        return fail("handshake", ec);

This one is fast and easy to use does all it needed

Now HTTP is very different story

    http::request<http::string_body> req;
    req.method(http::verb::get);
    req.target("/");
    req.version = 11;
    req.set(http::field::host, host + ":" +
        std::to_string(sock.remote_endpoint().port()));
    req.set(http::field::user_agent, BEAST_VERSION_STRING);
    req.prepare_payload();

Most of stuff can be defined there by default: version 1.1, Host header -
required by http/1.1 why should I bother? User agent put one by default
unless user wants - you do all this stuff for WS handshake so why not
there? Why so complicated?

-----------------

Protocol Premier HTTP/1.1 example without host. Your example isn't valid
HTTP /1.1 request.

HTTP /1.1 unlike 1.0 requires host header

Artyom


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk