Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions include/cpp_request/response.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <string>
#include <string_view>

#include <cpp_request/headers.hpp>

namespace cpp_request {

namespace detail::http {
class ResponseParser;
}

class Response {
public:
[[nodiscard]] int status_code() const noexcept { return status_code_; }
[[nodiscard]] std::string_view reason() const noexcept { return reason_; }
[[nodiscard]] const Headers& headers() const noexcept { return headers_; }
[[nodiscard]] std::string_view body() const noexcept { return body_; }
[[nodiscard]] const std::string& body_storage() const noexcept { return body_; }

private:
friend class detail::http::ResponseParser;

int status_code_{0};
std::string reason_;
Headers headers_;
std::string body_;
};

} // namespace cpp_request
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_library(internal
${CMAKE_CURRENT_SOURCE_DIR}/url.cpp
${CMAKE_CURRENT_SOURCE_DIR}/headers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/http/request_serializer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/http/response_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platform/native_socket.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platform/network_runtime.cpp
${CMAKE_CURRENT_SOURCE_DIR}/platform/socket_mode.cpp
Expand Down
Loading
Loading