22 #include <QNetworkReply> 26 #include <QStringList> 33 if ( !mReply )
return;
46 mHeaders.append( headers );
54 QRegExp re(
".*boundary=\"?([^\"]+)\"?\\s?", Qt::CaseInsensitive );
56 if ( !( re.
indexIn( contentType ) == 0 ) )
58 mError =
tr(
"Cannot find boundary in multipart content type" );
64 boundary =
"--" + boundary;
80 if ( data.
size() - from - 1 == 2 &&
QString( data.
mid( from, 2 ) ) ==
"--" )
87 if ( data.
size() - from > 1 )
99 while ( !part.
isEmpty() && ( part.
at( 0 ) ==
'\r' || part.
at( 0 ) ==
'\n' ) )
106 while ( pos < part.
size() - 1 )
108 if ( part.
at( pos ) ==
'\n' && ( part.
at( pos + 1 ) ==
'\n' || part.
at( pos + 1 ) ==
'\r' ) )
110 if ( part.
at( pos + 1 ) ==
'\r' ) pos++;
122 Q_FOREACH (
const QString& row, headerRows )
128 mHeaders.append( headersMap );
132 from = to + boundary.
length();
140 if ( !reply )
return false;
148 return contentType.
startsWith(
"multipart/", Qt::CaseInsensitive );
QString cap(int nth) const
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QList< RawHeaderMap > headers() const
Get headers.
QString tr(const char *sourceText, const char *disambiguation, int n)
static bool isMultipart(QNetworkReply *reply)
Test if reply is multipart.
int indexIn(const QString &str, int offset, CaretMode caretMode) const
int indexOf(char ch, int from) const
void append(const T &value)
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QgsNetworkReplyParser(QNetworkReply *reply)
Constructor.
QByteArray mid(int pos, int len) const
QByteArray left(int len) const
iterator insert(const Key &key, const T &value)
QByteArray & remove(int pos, int len)
QByteArray toAscii() const