QGIS API Documentation  2.99.0-Master (f867b65)
qgsnetworkreplyparser.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsnetworkreplyparser.h - Multipart QNetworkReply parser
3  -------------------
4  begin : 4 January, 2013
5  copyright : (C) 2013 by Radim Blazek
6  email : radim dot blazek at gmail.com
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSNETWORKREPLYPARSER_H
20 #define QGSNETWORKREPLYPARSER_H
21 
22 #define SIP_NO_FILE
23 
24 #include <QNetworkReply>
25 
26 #include "qgis_core.h"
27 
38 class CORE_EXPORT QgsNetworkReplyParser : public QObject
39 {
40  Q_OBJECT
41 
42  public:
43  typedef QMap<QByteArray, QByteArray> RawHeaderMap;
44 
47  QgsNetworkReplyParser( QNetworkReply *reply );
48 
51  bool isValid() const { return mValid; }
52 
55  int parts() const { return mHeaders.size(); }
56 
61  QByteArray rawHeader( int part, const QByteArray &headerName ) const { return mHeaders.value( part ).value( headerName ); }
62 
64  QList< RawHeaderMap > headers() const { return mHeaders; }
65 
69  QByteArray body( int part ) const { return mBodies.value( part ); }
70 
72  QList<QByteArray> bodies() const { return mBodies; }
73 
75  QString error() const { return mError; }
76 
79  static bool isMultipart( QNetworkReply *reply );
80 
81  private:
82  QNetworkReply *mReply = nullptr;
83 
84  bool mValid;
85 
86  QString mError;
87 
88  /* List of header maps */
89  QList< RawHeaderMap > mHeaders;
90 
91  /* List of part bodies */
92  QList<QByteArray> mBodies;
93 };
94 
95 #endif
QByteArray rawHeader(int part, const QByteArray &headerName) const
Get part header.
int parts() const
Get number of parts.
QList< RawHeaderMap > headers() const
Get headers.
QMap< QByteArray, QByteArray > RawHeaderMap
QByteArray body(int part) const
Get part part body.
bool isValid() const
Indicates if successfully parsed.
QString error() const
Parsing error.
Multipart QNetworkReply parser.
QList< QByteArray > bodies() const
Get bodies.