File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class SOURCEMETA_HYDRA_HTTP_EXPORT Response {
23
23
24
24
auto status () const noexcept -> Status;
25
25
auto header (const std::string &key) const -> std::optional<std::string>;
26
+ auto empty () noexcept -> bool;
26
27
auto body () -> std::istringstream &;
27
28
28
29
private:
Original file line number Diff line number Diff line change 1
1
#include < sourcemeta/hydra/http_response.h>
2
2
#include < sourcemeta/hydra/http_status.h>
3
3
4
+ #include < cassert> // assert
4
5
#include < map> // std::map
5
6
#include < optional> // std::optional, std::nullopt
6
7
#include < sstream> // std::ostringstream, std::istringstream
@@ -26,6 +27,11 @@ auto Response::header(const std::string &key) const
26
27
return this ->headers_ .at (key);
27
28
}
28
29
29
- auto Response::body () -> std::istringstream & { return this ->stream_ ; }
30
+ auto Response::empty () noexcept -> bool { return this ->stream_ .peek () == -1 ; }
31
+
32
+ auto Response::body () -> std::istringstream & {
33
+ assert (!this ->empty ());
34
+ return this ->stream_ ;
35
+ }
30
36
31
37
} // namespace sourcemeta::hydra::http
You can’t perform that action at this time.
0 commit comments