| Home | Libraries | People | FAQ | More

##### http::write (4 of 6 overloads)

Write a complete message to a stream.

###### Synopsis

Defined in header `<boost/beast/http/write.hpp>`

    template<
        class SyncWriteStream,
        bool isRequest,
        class Body,
        class Fields>
    std::size_t
    write(
        SyncWriteStream& stream,
        message< isRequest, Body, Fields > const& msg);

###### Description

This function is used to write a complete message to a stream using HTTP/1. The call will block until one of the following conditions is true:

- The entire message is written.
- An error occurs.

This operation is implemented in terms of one or more calls to the stream's `write_some` function. The algorithm will use a temporary `http::serializer` with an empty chunk decorator to produce buffers.

###### Remarks

This function only participates in overload resolution if `http::is_mutable_body_writer` for Body returns `false`.

###### Parameters

Name | Description
--- | ---
`stream` | The stream to which the data is to be written. The type must support the SyncWriteStream concept.
`msg` | The message to write.

###### Return Value

The number of bytes written to the stream.

###### Exceptions

Type | Thrown On
--- | ---
`system_error` | Thrown on failure.

###### See Also

`http::message`

Convenience header `<boost/beast/http.hpp>`