QGIS API Documentation 3.99.0-Master (18a1e75d814)
Loading...
Searching...
No Matches
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
23#include "qgis_core.h"
24
25#include <QNetworkReply>
26
27#define SIP_NO_FILE
28
38
39class CORE_EXPORT QgsNetworkReplyParser : public QObject
40{
41 Q_OBJECT
42
43 public:
44 typedef QMap<QByteArray, QByteArray> RawHeaderMap;
45
50 QgsNetworkReplyParser( QNetworkReply *reply );
51
56 bool isValid() const { return mValid; }
57
62 int parts() const { return mHeaders.size(); }
63
70 QByteArray rawHeader( int part, const QByteArray &headerName ) const { return mHeaders.value( part ).value( headerName ); }
71
73 QList< RawHeaderMap > headers() const { return mHeaders; }
74
80 QByteArray body( int part ) const { return mBodies.value( part ); }
81
83 QList<QByteArray> bodies() const { return mBodies; }
84
86 QString error() const { return mError; }
87
92 static bool isMultipart( QNetworkReply *reply );
93
94 private:
95 QNetworkReply *mReply = nullptr;
96
97 bool mValid = false;
98
99 QString mError;
100
101 /* List of header maps */
102 QList< RawHeaderMap > mHeaders;
103
104 /* List of part bodies */
105 QList<QByteArray> mBodies;
106};
107
108#endif
bool isValid() const
Indicates if successfully parsed.
int parts() const
Gets number of parts.
QMap< QByteArray, QByteArray > RawHeaderMap
QgsNetworkReplyParser(QNetworkReply *reply)
Constructor.
QByteArray body(int part) const
Gets part part body.
QByteArray rawHeader(int part, const QByteArray &headerName) const
Gets part header.
QList< RawHeaderMap > headers() const
Gets headers.
QString error() const
Parsing error.
QList< QByteArray > bodies() const
Gets bodies.