perform a head request
| 44 | |
| 45 | // perform a head request |
| 46 | void 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 |