MySQL 8.3.0
Source Code Documentation
http_request_impl.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#include <system_error>
26
27#include <event2/http.h>
29
31 public:
33 std::unique_ptr<evhttp_request, std::function<void(evhttp_request *)>>;
34
35 int error_code{0};
36 std::error_code socket_error_code_;
37
39
40 impl(evhttp_req_type request) : req{std::move(request)} {}
41
42 void own() { owns_http_request = true; }
43
44 void disown() { owns_http_request = false; }
45
47 // there are two ways to drop ownership of the wrapped
48 // evhttp_request:
49 //
50 // - before evhttp_make_request(), HttpRequest owns the evhttp_request
51 // - after evhttp_make_request(), ownership moves to the event-loop
52 // - after the eventloop is done, it free()s the evhttp_request if no one
53 // called "evhttp_request_own"
54 // - ... in which case HttpRequest stays the owner and has to free it
55 if (req && !evhttp_request_is_owned(req.get()) && !owns_http_request) {
56 req.release();
57 }
58 }
59
60 private:
62};
Definition: http_request_impl.h:30
void disown()
Definition: http_request_impl.h:44
evhttp_req_type req
Definition: http_request_impl.h:38
~impl()
Definition: http_request_impl.h:46
void own()
Definition: http_request_impl.h:42
impl(evhttp_req_type request)
Definition: http_request_impl.h:40
bool owns_http_request
Definition: http_request_impl.h:61
int error_code
Definition: http_request_impl.h:35
std::unique_ptr< evhttp_request, std::function< void(evhttp_request *)> > evhttp_req_type
Definition: http_request_impl.h:33
std::error_code socket_error_code_
Definition: http_request_impl.h:36
Definition: varlen_sort.h:174
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:2437