mirror of https://github.com/CrowCpp/Crow.git
Update http_connection.h, http_request.h, and http_response.h
This commit is contained in:
parent
4e801d085a
commit
b81e76f68a
|
@ -319,6 +319,7 @@ namespace crow
|
|||
ctx_ = detail::context<Middlewares...>();
|
||||
req.middleware_context = (void*)&ctx_;
|
||||
req.io_service = &adaptor_.get_io_service();
|
||||
req.adaptor = &adaptor_;
|
||||
detail::middleware_call_helper<0, decltype(ctx_), decltype(*middlewares_), Middlewares...>(*middlewares_, req, res, ctx_);
|
||||
|
||||
if (!res.completed_)
|
||||
|
@ -393,15 +394,22 @@ namespace crow
|
|||
res.set_header("location", location);
|
||||
}
|
||||
|
||||
prepare_buffers();
|
||||
CROW_LOG_INFO << "Response: " << this << ' ' << req_.raw_url << ' ' << res.code << ' ' << close_connection_;
|
||||
if (res.is_static_type())
|
||||
prepare_buffers();
|
||||
CROW_LOG_INFO << "Response: " << this << ' ' << req_.raw_url << ' ' << res.code << (res.manual_ ? " Manual " : " ") << close_connection_;
|
||||
if (!res.manual_)
|
||||
{
|
||||
do_write_static();
|
||||
}else {
|
||||
do_write_general();
|
||||
if (res.is_static_type())
|
||||
{
|
||||
do_write_static();
|
||||
}else {
|
||||
do_write_general();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
is_writing = true;
|
||||
boost::asio::write(adaptor_.socket(), buffers_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -472,7 +480,7 @@ namespace crow
|
|||
|
||||
}
|
||||
|
||||
if (!res.headers.count("content-length"))
|
||||
if (!res.headers.count("content-length") && !res.manual_)
|
||||
{
|
||||
content_length_ = std::to_string(res.body.size());
|
||||
static std::string content_length_tag = "Content-Length: ";
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "crow/common.h"
|
||||
#include "crow/ci_map.h"
|
||||
#include "crow/query_string.h"
|
||||
#include "crow/socket_adaptors.h"
|
||||
|
||||
namespace crow
|
||||
{
|
||||
|
@ -35,6 +36,7 @@ namespace crow
|
|||
|
||||
void* middleware_context{};
|
||||
boost::asio::io_service* io_service{};
|
||||
SocketAdaptor* adaptor;
|
||||
|
||||
/// Construct an empty request. (sets the method to `GET`)
|
||||
request()
|
||||
|
|
|
@ -232,10 +232,21 @@ namespace crow
|
|||
}
|
||||
}
|
||||
|
||||
template<typename Adaptor>
|
||||
void send_chunk(Adaptor& adaptor, const std::string& data)
|
||||
{
|
||||
manual_ = true;
|
||||
end();
|
||||
std::vector<boost::asio::const_buffer> buffers;
|
||||
buffers.push_back(boost::asio::buffer(data));
|
||||
write_buffer_list(buffers, adaptor);
|
||||
}
|
||||
|
||||
private:
|
||||
bool completed_{};
|
||||
std::function<void()> complete_request_handler_;
|
||||
std::function<bool()> is_alive_helper_;
|
||||
bool manual_ = false;
|
||||
static_file_info file_info;
|
||||
|
||||
template<typename Stream, typename Adaptor>
|
||||
|
|
Loading…
Reference in New Issue