MCPcopy Create free account
hub / github.com/boostorg/beast / do_head

Function do_head

example/http/client/methods/http_client_methods.cpp:46–69  ·  view source on GitHub ↗

perform a head request

Source from the content-addressed store, hash-verified

44
45// perform a head request
46void do_head(beast::tcp_stream & stream,
47 http::request<http::string_body> & req,
48 beast::flat_buffer buffer,
49 http::response<http::dynamic_body> & res)
50{
51 // we reuse the get endpoint
52 req.target("/get");
53 req.method(beast::http::verb::head);
54 http::write(stream, req);
55
56 /* the head response will send back a content-length
57 * without a body. The other requests don't set content-length when not
58 * sending a body back.
59 *
60 * the response parser doesn't know that we sent head,
61 * so we need to manually make sure we're only reading the header
62 * otherwise we're waiting forever for data.
63 */
64
65 http::response_parser<http::dynamic_body> p;
66 http::read_header(stream, buffer, p);
67 // move the result over
68 res = p.release();
69}
70
71
72// perform a patch request

Callers 1

mainFunction · 0.85

Calls 5

read_headerFunction · 0.85
targetMethod · 0.80
methodMethod · 0.80
releaseMethod · 0.80
writeFunction · 0.50

Tested by

no test coverage detected