MySQL 8.0.40
Source Code Documentation
http_request_impl.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#include <system_error>
27
28#include <event2/http.h>
30
32 public:
34 std::unique_ptr<evhttp_request, std::function<void(evhttp_request *)>>;
35
36 int error_code{0};
37 std::error_code socket_error_code_;
38
40
41 impl(evhttp_req_type request) : req{std::move(request)} {}
42
43 void own() { owns_http_request = true; }
44
45 void disown() { owns_http_request = false; }
46
48 // there are two ways to drop ownership of the wrapped
49 // evhttp_request:
50 //
51 // - before evhttp_make_request(), HttpRequest owns the evhttp_request
52 // - after evhttp_make_request(), ownership moves to the event-loop
53 // - after the eventloop is done, it free()s the evhttp_request if no one
54 // called "evhttp_request_own"
55 // - ... in which case HttpRequest stays the owner and has to free it
56 if (req && !evhttp_request_is_owned(req.get()) && !owns_http_request) {
57 req.release();
58 }
59 }
60
61 private:
63};
Definition: http_request_impl.h:31
void disown()
Definition: http_request_impl.h:45
evhttp_req_type req
Definition: http_request_impl.h:39
~impl()
Definition: http_request_impl.h:47
void own()
Definition: http_request_impl.h:43
impl(evhttp_req_type request)
Definition: http_request_impl.h:41
bool owns_http_request
Definition: http_request_impl.h:62
int error_code
Definition: http_request_impl.h:36
std::unique_ptr< evhttp_request, std::function< void(evhttp_request *)> > evhttp_req_type
Definition: http_request_impl.h:34
std::error_code socket_error_code_
Definition: http_request_impl.h:37
Definition: gcs_xcom_synode.h:64
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2439