Bump to 17.31.23
[platform/upstream/libzypp.git] / zypp-curl / transfersettings.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file zypp-curl/TransferSettings
10  *
11  */
12 #ifndef ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
13 #define ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
14
15 #include <string>
16 #include <vector>
17 #include <zypp-core/base/Flags.h>
18 #include <zypp-core/base/PtrTypes.h>
19 #include <zypp-core/Pathname.h>
20 #include <zypp-core/Url.h>
21 namespace zypp
22 {
23   namespace media
24   {
25
26     ///////////////////////////////////////////////////////////////////
27     /// \brief Holds transfer setting
28     ///
29     /// \note bsc#1212187: HTTP/2 RFC 9113 forbids fields ending with a
30     /// space. The class asserts \ref headers and \ref userAgentString
31     /// return trimmed strings. Strings are trimmed when set. Empty
32     //  strings are discarded.
33     class TransferSettings
34     {
35     public:
36       /** Constructs a transfer program cmd line access. */
37       TransferSettings();
38
39       typedef std::vector<std::string> Headers;
40
41       /** reset the settings to the defaults */
42       void reset();
43
44       /** add a header, on the form "Foo: Bar" (trims)*/
45       void addHeader( std::string && val_r );
46       void addHeader( const std::string & val_r );
47
48       /** returns a list of all added headers (trimmed) */
49       const Headers &headers() const;
50
51       /** sets the user agent ie: "Mozilla v3" (trims) */
52       void setUserAgentString( std::string && val_r );
53       void setUserAgentString( const std::string &val_r );
54
55       /** user agent string (trimmed)*/
56       const std::string &userAgentString() const;
57
58
59       /** sets the auth username */
60       void setUsername( const std::string &val_r );
61       void setUsername( std::string && val_r );
62
63       /** auth username */
64       const std::string &username() const;
65
66       /** sets the auth password */
67       void setPassword( const std::string & val_r );
68       void setPassword( std::string && val_r );
69
70       /** auth password */
71       const std::string &password() const;
72
73       /** returns the user and password as a user:pass string */
74       std::string userPassword() const;
75
76       /** sets anonymous authentication (ie: for ftp) */
77       void setAnonymousAuth();
78
79
80       /** whether the proxy is used or not */
81       void setProxyEnabled( bool enabled );
82
83       /** proxy is enabled */
84       bool proxyEnabled() const;
85
86
87       /** proxy to use if it is enabled */
88       void setProxy( const std::string &val_r );
89       void setProxy( std::string && val_r );
90
91       /** proxy host */
92       const std::string &proxy() const;
93
94
95       /** sets the proxy user */
96       void setProxyUsername( const std::string &val_r );
97       void setProxyUsername( std::string && val_r );
98
99       /** proxy auth username */
100       const std::string &proxyUsername() const;
101
102       /** sets the proxy password */
103       void setProxyPassword( const std::string &val_r );
104       void setProxyPassword( std::string && val_r );
105
106       /** proxy auth password */
107       const std::string &proxyPassword() const;
108
109       /** returns the proxy user and password as a user:pass string */
110       std::string proxyUserPassword() const;
111
112
113       /** set the connect timeout */
114       void setConnectTimeout( long t );
115
116       /** connection timeout */
117       long connectTimeout() const;
118
119
120       /** set the transfer timeout */
121       void setTimeout( long t );
122
123       /** transfer timeout */
124       long timeout() const;
125
126
127       /** Set maximum number of concurrent connections for a single transfer */
128       void setMaxConcurrentConnections(long v);
129
130       /** Maximum number of concurrent connections for a single transfer */
131       long maxConcurrentConnections() const;
132
133
134       /** Set minimum download speed (bytes per second) until the connection is dropped */
135       void setMinDownloadSpeed(long v);
136
137       /** Minimum download speed (bytes per second) until the connection is dropped */
138       long minDownloadSpeed() const;
139
140
141       /** Set max download speed (bytes per second) */
142       void setMaxDownloadSpeed(long v);
143
144       /** Maximum download speed (bytes per second) */
145       long maxDownloadSpeed() const;
146
147
148       /** Set maximum silent retries */
149       void setMaxSilentTries(long v);
150
151       /** Maximum silent retries */
152       long maxSilentTries() const;
153
154
155       /** Sets whether to verify host for ssl */
156       void setVerifyHostEnabled( bool enabled );
157
158       /** Whether to verify host for ssl */
159       bool verifyHostEnabled() const;
160
161
162       /** Sets whether to verify host for ssl */
163       void setVerifyPeerEnabled( bool enabled );
164
165       /** Whether to verify peer for ssl */
166       bool verifyPeerEnabled() const;
167
168
169       /** Sets the SSL certificate authorities path */
170       void setCertificateAuthoritiesPath( const Pathname &val_r );
171       void setCertificateAuthoritiesPath( Pathname && val_r );
172
173       /** SSL certificate authorities path ( default: /etc/ssl/certs ) */
174       const Pathname &certificateAuthoritiesPath() const;
175
176
177       /** set the allowed authentication types */
178       void setAuthType( const std::string &val_r );
179       void setAuthType( std::string && val_r );
180
181       /** get the allowed authentication types */
182       const std::string &authType() const;
183
184
185       /** set whether HEAD requests are allowed */
186       void setHeadRequestsAllowed(bool allowed);
187
188       /** whether HEAD requests are allowed */
189       bool headRequestsAllowed() const;
190
191
192       /** Sets the SSL client certificate file */
193       void setClientCertificatePath( const Pathname &val_r );
194       void setClientCertificatePath( Pathname && val_r );
195
196       /** SSL client certificate file */
197       const Pathname &clientCertificatePath() const;
198
199
200       /** Sets the SSL client key file */
201       void setClientKeyPath( const Pathname &val_r );
202       void setClientKeyPath( Pathname && val_r );
203
204       /** SSL client key file */
205       const Pathname &clientKeyPath() const;
206
207     protected:
208       class Impl;
209       RWCOW_pointer<Impl> _impl;
210     };
211
212   } // namespace media
213 } // namespece zypp
214
215 #endif // ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED