-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
was/{Glue,MGlue}: merge common code into class WasStockRequest
- Loading branch information
1 parent
f7baf50
commit a92ac7b
Showing
5 changed files
with
168 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
// Copyright CM4all GmbH | ||
// author: Max Kellermann <[email protected]> | ||
|
||
#include "SRequest.hxx" | ||
#include "SConnection.hxx" | ||
#include "SLease.hxx" | ||
#include "Client.hxx" | ||
#include "pool/pool.hxx" | ||
#include "stock/Item.hxx" | ||
#include "stock/Stock.hxx" | ||
|
||
inline void | ||
WasStockRequest::Destroy() noexcept | ||
{ | ||
DeleteFromPool(pool, this); | ||
} | ||
|
||
void | ||
WasStockRequest::OnStockItemReady(StockItem &item) noexcept | ||
{ | ||
auto &connection = static_cast<WasStockConnection &>(item); | ||
connection.SetSite(site_name); | ||
connection.SetUri(pending_request.uri); | ||
|
||
const auto &process = connection.GetSocket(); | ||
auto &lease = *NewFromPool<WasStockLease>(pool, connection); | ||
|
||
was_client_request(pool, item.GetStock().GetEventLoop(), | ||
std::move(stopwatch), | ||
process.control, | ||
process.input, process.output, | ||
lease, | ||
remote_host, | ||
pending_request.method, pending_request.uri, | ||
script_name, path_info, | ||
query_string, | ||
pending_request.headers, | ||
std::move(pending_request.body), | ||
parameters, | ||
metrics_handler, | ||
*this, cancel_ptr); | ||
} | ||
|
||
void | ||
WasStockRequest::OnStockItemError(std::exception_ptr ep) noexcept | ||
{ | ||
auto &_handler = handler; | ||
Destroy(); | ||
_handler.InvokeError(ep); | ||
} | ||
|
||
void | ||
WasStockRequest::OnHttpResponse(HttpStatus status, StringMap &&_headers, | ||
UnusedIstreamPtr _body) noexcept | ||
{ | ||
auto &_handler = handler; | ||
Destroy(); | ||
_handler.InvokeResponse(status, std::move(_headers), std::move(_body)); | ||
} | ||
|
||
void | ||
WasStockRequest::OnHttpError(std::exception_ptr error) noexcept | ||
{ | ||
auto &_handler = handler; | ||
Destroy(); | ||
_handler.InvokeError(std::move(error)); | ||
} | ||
|
||
void | ||
WasStockRequest::Cancel() noexcept | ||
{ | ||
auto c = std::move(cancel_ptr); | ||
Destroy(); | ||
c.Cancel(); | ||
} |
Oops, something went wrong.