reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
HttpProvider.hxx
Go to the documentation of this file.
1#ifndef RESIP_HttpProvider
2#define RESIP_HttpProvider
3
4#include "rutil/Mutex.hxx"
7#include <memory>
8#include <vector>
9
10namespace resip
11{
12class TransactionUser;
13class Data;
14class GenericUri;
15class TargetCommand;
16
17//To provide this functionality, plug in an instance of
18//HttpProviderFactory(before any instances of DialogUsageManager/SipStack are
19//created. Null will be returned by default.
20class HttpProviderFactory;
21
23{
24 // Per-endpoint-attempt connection establishment timeout (TCP connect + TLS handshake).
25 // On expiry the next resolved endpoint is tried. Must be > 0.
26 unsigned int mConnectTimeoutSeconds = 5;
27 // Overall wall-clock budget for the entire request: DNS resolution, all endpoint
28 // connection attempts, TLS handshake and response. 0 = no overall timeout.
29 unsigned int mRequestTimeoutSeconds = 0;
30
31 // Optional address access control list applied by the HTTP client to each IP address the
32 // target host resolves to (after DNS resolution). Deny wins; if mAllowedAddresses is
33 // non-empty a resolved address must match one of its entries. When all resolved addresses
34 // are filtered out, the request fails as if blocked by policy (see HttpGetMessage's
35 // blockedByPolicy flag). Both lists empty (the default) means no address filtering.
36 std::vector<AddressMask> mAllowedAddresses;
37 std::vector<AddressMask> mDeniedAddresses;
38};
39
41{
42 public:
43 //HttpProvider assumes memory
44 static void setFactory(std::unique_ptr<HttpProviderFactory> fact) noexcept;
45 //ptr so users can check for existence
46 static HttpProvider* instance();
47
48 //.dcm. tu param will become a postable
49 virtual void get(const GenericUri& target, const Data& tid, TransactionUser& tu, TargetCommand::Target& commandTarget)=0;
50 virtual void get(const GenericUri& target, const Data& tid, const Data& userData, const HttpRequestOptions& options, TransactionUser& tu, TargetCommand::Target& commandTarget) {} // Not =0 for back compat
51 virtual ~HttpProvider(){} //impl. singleton destructor pattern later
52 private:
53 static HttpProvider* mInstance;
54 static std::unique_ptr<HttpProviderFactory> mFactory;
55 static Mutex mMutex;
56};
57
59{
60 public:
63};
64}
65
66#endif
67
68/* ====================================================================
69 * The Vovida Software License, Version 1.0
70 *
71 * Copyright (c) 2026, SIP Spectrum, Inc. https://www.sipspectrum.com
72 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
73 *
74 * Redistribution and use in source and binary forms, with or without
75 * modification, are permitted provided that the following conditions
76 * are met:
77 *
78 * 1. Redistributions of source code must retain the above copyright
79 * notice, this list of conditions and the following disclaimer.
80 *
81 * 2. Redistributions in binary form must reproduce the above copyright
82 * notice, this list of conditions and the following disclaimer in
83 * the documentation and/or other materials provided with the
84 * distribution.
85 *
86 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
87 * and "Vovida Open Communication Application Library (VOCAL)" must
88 * not be used to endorse or promote products derived from this
89 * software without prior written permission. For written
90 * permission, please contact vocal@vovida.org.
91 *
92 * 4. Products derived from this software may not be called "VOCAL", nor
93 * may "VOCAL" appear in their name, without prior written
94 * permission of Vovida Networks, Inc.
95 *
96 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
97 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
98 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
99 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
100 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
101 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
102 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
103 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
104 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
105 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
106 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
107 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
108 * DAMAGE.
109 *
110 * ====================================================================
111 *
112 * This software consists of voluntary contributions made by Vovida
113 * Networks, Inc. and many individuals on behalf of Vovida Networks,
114 * Inc. For more information on Vovida Networks, Inc., please see
115 * <http://www.vovida.org/>.
116 *
117 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Represents the "absoluteURI" element in the RFC 3261 grammar.
virtual HttpProvider * createHttpProvider()=0
virtual void get(const GenericUri &target, const Data &tid, TransactionUser &tu, TargetCommand::Target &commandTarget)=0
static HttpProvider * instance()
static void setFactory(std::unique_ptr< HttpProviderFactory > fact) noexcept
virtual void get(const GenericUri &target, const Data &tid, const Data &userData, const HttpRequestOptions &options, TransactionUser &tu, TargetCommand::Target &commandTarget)
The base-class for an RFC 3261 Transaction User.
dcm! – add UnusedChecking(_enum) below;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
Definition Mutex.hxx:37
unsigned int mRequestTimeoutSeconds
std::vector< AddressMask > mDeniedAddresses
std::vector< AddressMask > mAllowedAddresses
unsigned int mConnectTimeoutSeconds