finish(error_code&) is a BodyReader requirement (API Change)

This commit is contained in:
Vinnie Falco
2017-06-09 14:55:44 -07:00
parent 64742a4183
commit b49b23ee83
10 changed files with 64 additions and 0 deletions

View File

@ -11,6 +11,7 @@ API Changes:
* Remove `opcode` from `read`, `async_read`
* `read_frame` returns `bool` fin
* `opcode` is private
* finish(error_code&) is a BodyReader requirement
Actions Required:

View File

@ -91,6 +91,14 @@ In this table:
or `false` if the buffer returned on this call is the last
buffer representing the body.
]
][
[`a.finish(ec)`]
[]
[
This function is called after the reader indicates there
are no more buffers remaining.
If `ec` is set, the error will be propagated to the caller.
]
][
[`is_body_reader<B>`]
[`std::true_type`]
@ -155,9 +163,18 @@ public:
A value of `false` means there is no more body data.
@li If `ec` contains an error code, the return value is ignored.
@param ec Set to the error, if any occurred.
*/
boost::optional<std::pair<const_buffers_type, bool>>
get(error_code& ec);
/** Called after `get` indicates there are no more buffers.
@param ec Set to the error, if any occurred.
*/
void
finish(error_code& ec);
};
```

View File

@ -90,6 +90,11 @@ struct file_body
offset_ += nread;
return {{const_buffers_type{buf_, nread}, offset_ < size_}};
}
void
finish(error_code&)
{
}
};
};

View File

@ -137,6 +137,11 @@ struct buffer_body
ec = error::need_buffer;
return boost::none;
}
void
finish(error_code&)
{
}
};
#endif

View File

@ -70,6 +70,11 @@ struct basic_dynamic_body
{
return {{body_.data(), false}};
}
void
finish(error_code&)
{
}
};
#endif

View File

@ -72,6 +72,11 @@ struct empty_body
{
return boost::none;
}
void
finish(error_code&)
{
}
};
#endif

View File

@ -250,6 +250,10 @@ get(error_code& ec, Visit&& visit)
break;
go_complete:
if(rd_)
rd_->finish(ec);
if(ec)
return;
s_ = do_complete;
break;
}

View File

@ -73,6 +73,11 @@ struct string_body
return {{const_buffers_type{
body_.data(), body_.size()}, false}};
}
void
finish(error_code&)
{
}
};
#endif

View File

@ -83,6 +83,7 @@ struct is_body_reader<T, beast::detail::void_t<
std::declval<boost::optional<std::pair<
typename T::reader::const_buffers_type, bool>>&>() =
std::declval<typename T::reader>().get(std::declval<error_code&>()),
std::declval<typename T::reader&>().finish(std::declval<error_code&>()),
(void)0)>> : std::integral_constant<bool,
is_const_buffer_sequence<
typename T::reader::const_buffers_type>::value &&

View File

@ -65,6 +65,11 @@ public:
return {{const_buffers_type{
body_.data(), body_.size()}, false}};
}
void
finish(error_code&)
{
}
};
};
@ -115,6 +120,11 @@ public:
std::integral_constant<bool, isFinalEmpty>{});
}
void
finish(error_code&)
{
}
private:
boost::optional<std::pair<const_buffers_type, bool>>
get(
@ -253,6 +263,12 @@ public:
return {{const_buffers_type{
body_.s_.data() + n_++, 1}, true}};
}
void
finish(error_code& ec)
{
body_.fc_.fail(ec);
}
};
};