diff 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
line wrap: on
line diff
--- a/ui/sslconnection_bare.h	Thu Aug 14 11:24:13 2014 +0200
+++ b/ui/sslconnection_bare.h	Mon Aug 18 18:51:33 2014 +0200
@@ -17,6 +17,8 @@
 #include <polarssl/error.h>
 #include <polarssl/certs.h>
 
+#include <QDateTime>
+
 /**
  * @file sslconnection_bare.h
  * @brief SSLConnection doing bare SSL over PolarSSL
@@ -30,23 +32,12 @@
 
     ~SSLConnectionBare();
 
-    /** @brief write */
-    int write(const QByteArray& request);
+    int connect();
 
-    /**
-     * @brief read at most len bytes and reset the connection
-     *
-     * @param [in] len Amount of bytes to read.
-     *
-     * @returns a byte array containing the data or
-     * a NULL byte array on error*/
-    QByteArray read(size_t len);
+    QDateTime getLastModifiedHeader(const QString &resource);
 
-    /** @brief: Establish the connection
-     *
-     * @returns 0 on success otherwise an error or -1 is returned
-     */
-    int connect();
+    bool downloadFile(const QString &resource, const QString &filename,
+                      size_t maxSize);
 
 private:
     x509_crt mX509PinnedCert;
@@ -82,6 +73,31 @@
 
     /* @brief disconnects the connection */
     void disconnect();
+
+    /**
+     * @brief parses the Headers of a repsonse.
+     *
+     * This removes the headers from the byte array passed as
+     * parameter.
+     *
+     * @param[inout] data: The response to parse.
+     *
+     * @returns: A map of the header fields. Or an empty map on error.
+     */
+    QMap<QString, QString> parseHeaders(QByteArray *data);
+
+    /** @brief write */
+    int write(const QByteArray& request);
+
+    /**
+     * @brief read at most len bytes and reset the connection
+     *
+     * @param [in] len Amount of bytes to read.
+     *
+     * @returns a byte array containing the data or
+     * a NULL byte array on error*/
+    QByteArray read(size_t len);
+
 };
 
 #endif // UI_SSLCONNECTION_BARE_H

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