Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <RequestServer/ConnectionFromClient.h>
8#include <RequestServer/Request.h>
9
10namespace RequestServer {
11
12// FIXME: What about rollover?
13static i32 s_next_id = 1;
14
15Request::Request(ConnectionFromClient& client, NonnullOwnPtr<Core::File>&& output_stream)
16 : m_client(client)
17 , m_id(s_next_id++)
18 , m_output_stream(move(output_stream))
19{
20}
21
22void Request::stop()
23{
24 m_client.did_finish_request({}, *this, false);
25}
26
27void Request::set_response_headers(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers)
28{
29 m_response_headers = response_headers;
30 m_client.did_receive_headers({}, *this);
31}
32
33void Request::set_certificate(DeprecatedString, DeprecatedString)
34{
35}
36
37void Request::did_finish(bool success)
38{
39 m_client.did_finish_request({}, *this, success);
40}
41
42void Request::did_progress(Optional<u32> total_size, u32 downloaded_size)
43{
44 m_total_size = total_size;
45 m_downloaded_size = downloaded_size;
46 m_client.did_progress_request({}, *this);
47}
48
49void Request::did_request_certificates()
50{
51 m_client.did_request_certificates({}, *this);
52}
53
54}