comparison ui/sslconnection_bare.h @ 910:eaed02defe6a

More SSLConnection refactoring. Fixes curl downloader.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 18 Aug 2014 18:51:33 +0200
parents d1c951b3012d
children 2949f1842955
comparison
equal deleted inserted replaced
909:18e3ad073b38 910:eaed02defe6a
15 #include <polarssl/ssl.h> 15 #include <polarssl/ssl.h>
16 #include <polarssl/ctr_drbg.h> 16 #include <polarssl/ctr_drbg.h>
17 #include <polarssl/error.h> 17 #include <polarssl/error.h>
18 #include <polarssl/certs.h> 18 #include <polarssl/certs.h>
19 19
20 #include <QDateTime>
21
20 /** 22 /**
21 * @file sslconnection_bare.h 23 * @file sslconnection_bare.h
22 * @brief SSLConnection doing bare SSL over PolarSSL 24 * @brief SSLConnection doing bare SSL over PolarSSL
23 * */ 25 * */
24 26
28 SSLConnectionBare(const QString& url, 30 SSLConnectionBare(const QString& url,
29 const QByteArray& certificate = QByteArray()); 31 const QByteArray& certificate = QByteArray());
30 32
31 ~SSLConnectionBare(); 33 ~SSLConnectionBare();
32 34
33 /** @brief write */ 35 int connect();
34 int write(const QByteArray& request);
35 36
36 /** 37 QDateTime getLastModifiedHeader(const QString &resource);
37 * @brief read at most len bytes and reset the connection
38 *
39 * @param [in] len Amount of bytes to read.
40 *
41 * @returns a byte array containing the data or
42 * a NULL byte array on error*/
43 QByteArray read(size_t len);
44 38
45 /** @brief: Establish the connection 39 bool downloadFile(const QString &resource, const QString &filename,
46 * 40 size_t maxSize);
47 * @returns 0 on success otherwise an error or -1 is returned
48 */
49 int connect();
50 41
51 private: 42 private:
52 x509_crt mX509PinnedCert; 43 x509_crt mX509PinnedCert;
53 entropy_context mEntropy; 44 entropy_context mEntropy;
54 ctr_drbg_context mCtr_drbg; 45 ctr_drbg_context mCtr_drbg;
80 * @returns: 0 on success a polarssl error or -1 otherwise. */ 71 * @returns: 0 on success a polarssl error or -1 otherwise. */
81 int validateCertificate(); 72 int validateCertificate();
82 73
83 /* @brief disconnects the connection */ 74 /* @brief disconnects the connection */
84 void disconnect(); 75 void disconnect();
76
77 /**
78 * @brief parses the Headers of a repsonse.
79 *
80 * This removes the headers from the byte array passed as
81 * parameter.
82 *
83 * @param[inout] data: The response to parse.
84 *
85 * @returns: A map of the header fields. Or an empty map on error.
86 */
87 QMap<QString, QString> parseHeaders(QByteArray *data);
88
89 /** @brief write */
90 int write(const QByteArray& request);
91
92 /**
93 * @brief read at most len bytes and reset the connection
94 *
95 * @param [in] len Amount of bytes to read.
96 *
97 * @returns a byte array containing the data or
98 * a NULL byte array on error*/
99 QByteArray read(size_t len);
100
85 }; 101 };
86 102
87 #endif // UI_SSLCONNECTION_BARE_H 103 #endif // UI_SSLCONNECTION_BARE_H

http://wald.intevation.org/projects/trustbridge/