1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp-curl/TransferSettings
12 #ifndef ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
13 #define ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
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>
26 ///////////////////////////////////////////////////////////////////
27 /// \brief Holds transfer setting
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
36 /** Constructs a transfer program cmd line access. */
39 typedef std::vector<std::string> Headers;
41 /** reset the settings to the defaults */
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 );
48 /** returns a list of all added headers (trimmed) */
49 const Headers &headers() const;
51 /** sets the user agent ie: "Mozilla v3" (trims) */
52 void setUserAgentString( std::string && val_r );
53 void setUserAgentString( const std::string &val_r );
55 /** user agent string (trimmed)*/
56 const std::string &userAgentString() const;
59 /** sets the auth username */
60 void setUsername( const std::string &val_r );
61 void setUsername( std::string && val_r );
64 const std::string &username() const;
66 /** sets the auth password */
67 void setPassword( const std::string & val_r );
68 void setPassword( std::string && val_r );
71 const std::string &password() const;
73 /** returns the user and password as a user:pass string */
74 std::string userPassword() const;
76 /** sets anonymous authentication (ie: for ftp) */
77 void setAnonymousAuth();
80 /** whether the proxy is used or not */
81 void setProxyEnabled( bool enabled );
83 /** proxy is enabled */
84 bool proxyEnabled() const;
87 /** proxy to use if it is enabled */
88 void setProxy( const std::string &val_r );
89 void setProxy( std::string && val_r );
92 const std::string &proxy() const;
95 /** sets the proxy user */
96 void setProxyUsername( const std::string &val_r );
97 void setProxyUsername( std::string && val_r );
99 /** proxy auth username */
100 const std::string &proxyUsername() const;
102 /** sets the proxy password */
103 void setProxyPassword( const std::string &val_r );
104 void setProxyPassword( std::string && val_r );
106 /** proxy auth password */
107 const std::string &proxyPassword() const;
109 /** returns the proxy user and password as a user:pass string */
110 std::string proxyUserPassword() const;
113 /** set the connect timeout */
114 void setConnectTimeout( long t );
116 /** connection timeout */
117 long connectTimeout() const;
120 /** set the transfer timeout */
121 void setTimeout( long t );
123 /** transfer timeout */
124 long timeout() const;
127 /** Set maximum number of concurrent connections for a single transfer */
128 void setMaxConcurrentConnections(long v);
130 /** Maximum number of concurrent connections for a single transfer */
131 long maxConcurrentConnections() const;
134 /** Set minimum download speed (bytes per second) until the connection is dropped */
135 void setMinDownloadSpeed(long v);
137 /** Minimum download speed (bytes per second) until the connection is dropped */
138 long minDownloadSpeed() const;
141 /** Set max download speed (bytes per second) */
142 void setMaxDownloadSpeed(long v);
144 /** Maximum download speed (bytes per second) */
145 long maxDownloadSpeed() const;
148 /** Set maximum silent retries */
149 void setMaxSilentTries(long v);
151 /** Maximum silent retries */
152 long maxSilentTries() const;
155 /** Sets whether to verify host for ssl */
156 void setVerifyHostEnabled( bool enabled );
158 /** Whether to verify host for ssl */
159 bool verifyHostEnabled() const;
162 /** Sets whether to verify host for ssl */
163 void setVerifyPeerEnabled( bool enabled );
165 /** Whether to verify peer for ssl */
166 bool verifyPeerEnabled() const;
169 /** Sets the SSL certificate authorities path */
170 void setCertificateAuthoritiesPath( const Pathname &val_r );
171 void setCertificateAuthoritiesPath( Pathname && val_r );
173 /** SSL certificate authorities path ( default: /etc/ssl/certs ) */
174 const Pathname &certificateAuthoritiesPath() const;
177 /** set the allowed authentication types */
178 void setAuthType( const std::string &val_r );
179 void setAuthType( std::string && val_r );
181 /** get the allowed authentication types */
182 const std::string &authType() const;
185 /** set whether HEAD requests are allowed */
186 void setHeadRequestsAllowed(bool allowed);
188 /** whether HEAD requests are allowed */
189 bool headRequestsAllowed() const;
192 /** Sets the SSL client certificate file */
193 void setClientCertificatePath( const Pathname &val_r );
194 void setClientCertificatePath( Pathname && val_r );
196 /** SSL client certificate file */
197 const Pathname &clientCertificatePath() const;
200 /** Sets the SSL client key file */
201 void setClientKeyPath( const Pathname &val_r );
202 void setClientKeyPath( Pathname && val_r );
204 /** SSL client key file */
205 const Pathname &clientKeyPath() const;
209 RWCOW_pointer<Impl> _impl;
215 #endif // ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED