Skip to content

Commit

Permalink
Merge pull request #28 from 5cript/feat/boost_compat_update
Browse files Browse the repository at this point in the history
Fixed code to work with newer boost beast.
  • Loading branch information
5cript authored Dec 4, 2024
2 parents c47f730 + ad12913 commit f1ff891
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 42 deletions.
30 changes: 0 additions & 30 deletions include/roar/beast/forward.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion include/roar/directory_server/directory_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ namespace Roar::Detail
else
{
RangeFileBody::value_type body;
boost::beast::error_code ec;
std::error_code ec;
body.open(fileAndStatus.file.string().c_str(), std::ios_base::in, ec);
if (ec)
return session.sendStandardResponse(
Expand Down
2 changes: 0 additions & 2 deletions include/roar/error.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <roar/beast/forward.hpp>

#include <boost/system/system_error.hpp>

#include <string>
Expand Down
15 changes: 10 additions & 5 deletions include/roar/request.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <boost/utility/string_view_fwd.hpp>
#include <roar/mechanics/cookie.hpp>
#include <roar/authorization/basic_auth.hpp>
#include <roar/authorization/digest_auth.hpp>
Expand Down Expand Up @@ -95,12 +96,13 @@ namespace Roar

void target(std::string_view target)
{
static_cast<beast_request*>(this)->target(target);
static_cast<beast_request*>(this)->target(boost::string_view{target.data(), target.size()});
parseTarget();
}
std::string_view target() const
{
return static_cast<beast_request const*>(this)->target();
auto target = static_cast<beast_request const*>(this)->target();
return std::string_view{target.data(), target.size()};
}

Request<BodyT>& host(std::string&& host)
Expand Down Expand Up @@ -345,7 +347,8 @@ namespace Roar
auto spacePos = iter->value().find(' ');
if (spacePos == std::string::npos)
return std::nullopt;
return authorizationSchemeFromString(iter->value().substr(0, spacePos));
auto boostView = iter->value().substr(0, spacePos);
return authorizationSchemeFromString(std::string_view{boostView.data(), boostView.size()});
}

/**
Expand All @@ -362,7 +365,8 @@ namespace Roar
return std::nullopt;
if (value.substr(0, spacePos) != "Basic")
return std::nullopt;
return BasicAuth::fromBase64(value.substr(spacePos + 1, value.size() - spacePos - 1));
auto boostView = value.substr(spacePos + 1, value.size() - spacePos - 1);
return BasicAuth::fromBase64(std::string_view{boostView.data(), boostView.size()});
}

Request<BodyT>& basicAuth(BasicAuth const& auth)
Expand All @@ -385,7 +389,8 @@ namespace Roar
return std::nullopt;
if (value.substr(0, spacePos) != "Digest")
return std::nullopt;
return DigestAuth::fromParameters(value.substr(spacePos + 1));
auto boostView = value.substr(spacePos + 1);
return DigestAuth::fromParameters(std::string_view{boostView.data(), boostView.size()});
}

Request<BodyT>& digestAuth(DigestAuth const& auth)
Expand Down
1 change: 0 additions & 1 deletion include/roar/server.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <roar/directory_server/directory_server.hpp>
#include <roar/beast/forward.hpp>
#include <roar/routing/proto_route.hpp>
#include <roar/error.hpp>
#include <roar/session/session.hpp>
Expand Down
1 change: 0 additions & 1 deletion include/roar/session/factory.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <roar/beast/forward.hpp>
#include <roar/detail/pimpl_special_functions.hpp>
#include <roar/ssl/make_ssl_context.hpp>
#include <roar/standard_response_provider.hpp>
Expand Down
1 change: 0 additions & 1 deletion include/roar/session/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <roar/error.hpp>
#include <roar/websocket/websocket_session.hpp>
#include <roar/response.hpp>
#include <roar/beast/forward.hpp>
#include <roar/detail/pimpl_special_functions.hpp>
#include <roar/literals/memory.hpp>
#include <roar/routing/proto_route.hpp>
Expand Down
2 changes: 1 addition & 1 deletion test/test_http_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace Roar::Tests
return session.sendStandardResponse(status::bad_request, "Cannot parse ranges.");

RangeFileBody::value_type body;
boost::beast::error_code ec;
std::error_code ec;
body.open(tempDir_.path() / "index.txt", std::ios_base::in, ec);
if (ec)
return session.sendStandardResponse(status::internal_server_error, "Cannot open file for reading.");
Expand Down

0 comments on commit f1ff891

Please sign in to comment.