blob: 99d7713f6ec38e77dd1e4ca89064e9934defb285 [file] [log] [blame]
Leo Lai16dea872019-12-06 10:39:21 +08001// Copyright 2015 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Alex Vakulenkofdb42ae2015-09-25 11:23:00 -07004
5#ifndef WEBSERVER_LIBWEBSERV_REQUEST_UTILS_H_
6#define WEBSERVER_LIBWEBSERV_REQUEST_UTILS_H_
7
8#include <memory>
9#include <vector>
10
11#include <base/callback_forward.h>
Alex Vakulenko9e1596d2015-10-13 10:01:34 -070012#include <brillo/errors/error.h>
Alex Vakulenkofdb42ae2015-09-25 11:23:00 -070013#include <libwebserv/export.h>
14
15namespace libwebserv {
16
17class Request;
18class Response;
19
20using GetRequestDataSuccessCallback =
21 base::Callback<void(std::unique_ptr<Request> request,
22 std::unique_ptr<Response> response,
23 std::vector<uint8_t> data)>;
24
25using GetRequestDataErrorCallback =
26 base::Callback<void(std::unique_ptr<Request> request,
27 std::unique_ptr<Response> response,
Alex Vakulenko9e1596d2015-10-13 10:01:34 -070028 const brillo::Error* error)>;
Alex Vakulenkofdb42ae2015-09-25 11:23:00 -070029
30// Reads the request data from |request| asynchronously and returns the data
31// by calling |success_callback|. If an error occurred, |error_callback| is
32// invoked with the error information passed into |error| parameter.
33// The function takes ownership of the request and response objects for the
34// duration of operation and returns them back via the callbacks.
35LIBWEBSERV_EXPORT void GetRequestData(
36 std::unique_ptr<Request> request,
37 std::unique_ptr<Response> response,
38 const GetRequestDataSuccessCallback& success_callback,
39 const GetRequestDataErrorCallback& error_callback);
40
41} // namespace libwebserv
42
43#endif // WEBSERVER_LIBWEBSERV_REQUEST_UTILS_H_