Browse Source

Simplify multipart form parsing code and add debug

adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
2036326403
  1. 5
      src/webui/httprequestparser.cpp

5
src/webui/httprequestparser.cpp

@ -87,6 +87,7 @@ void HttpRequestParser::write(const QByteArray& ba) { @@ -87,6 +87,7 @@ void HttpRequestParser::write(const QByteArray& ba) {
// Parse message content
if (m_header.hasContentLength()) {
qDebug() << Q_FUNC_INFO << "header: " << ba.left(end_of_header);
m_data = ba.mid(end_of_header + 4, m_header.contentLength()); // +4 to skip "\r\n\r\n"
// Parse POST data
@ -101,7 +102,9 @@ void HttpRequestParser::write(const QByteArray& ba) { @@ -101,7 +102,9 @@ void HttpRequestParser::write(const QByteArray& ba) {
} else {
// Parse form data (torrent file)
if(m_header.contentType() == "multipart/form-data") {
m_torrentContent = m_data.right(m_data.size()-m_data.indexOf("\r\n\r\n")-QByteArray("\r\n\r\n").size());
qDebug() << "form-part header: " << m_data.left(m_data.indexOf("\r\n\r\n"));
m_torrentContent = m_data.mid(m_data.indexOf("\r\n\r\n") + 4);
qDebug() << Q_FUNC_INFO << "m_torrentContent.size(): " << m_torrentContent.size();
}
}
}

Loading…
Cancel
Save