Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiPart post network request stopped working #46989

Closed
1 of 2 tasks
raymondnijssen opened this issue Jan 25, 2022 · 3 comments · Fixed by #47006
Closed
1 of 2 tasks

MultiPart post network request stopped working #46989

raymondnijssen opened this issue Jan 25, 2022 · 3 comments · Fixed by #47006
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers PyQGIS Related to the PyQGIS API

Comments

@raymondnijssen
Copy link
Contributor

What is the bug or the crash?

One of my plugins stopped working in QGIS master, because some of the requests seem invalid. Specifically requests that post data data with a file as multipart content do not work

Steps to reproduce the issue

Not easy to reproduce by clicking, but I wrote a script to test this. I posted it on the developer mailing list: https://lists.osgeo.org/pipermail/qgis-developer/2022-January/064437.html

Versions

Well it depends on the versions. I've been building many to get close to the date it broke:
14 sep: works
1 oct: works
1 dec: works
7 dec: broken
16 dec: broken
1 jan: broken
23 jan: broken

Here's the output for my December 7 build:

<style type="text/css"> p, li { white-space: pre-wrap; } </style>
QGIS version 3.23.0-Master QGIS code revision be56138
Qt version 5.12.8
Python version 3.8.10
GDAL/OGR version 3.0.4
PROJ version 6.3.1
EPSG Registry database version v9.8.6 (2020-01-22)
Compiled against GEOS 3.8.0-CAPI-1.13.1 Running against GEOS 3.8.0-CAPI-1.13.1
SQLite version 3.31.1
PDAL version 2.0.1
PostgreSQL client version 12.9 (Ubuntu 12.9-0ubuntu0.20.04.1)
SpatiaLite version 4.3.0a
QWT version 6.1.4
QScintilla2 version 2.11.2
OS version Ubuntu 20.04.3 LTS
       
Active Python plugins
ImaerPlugin version 3.1.0
plugin_reloader 0.9.1
pdokservicesplugin 3.7.3
qgis_3d_ams 0.1
QuickOSM 2.0.0
firstaid 2.1.5
QCopycanvas 0.5
sagaprovider 2.12.99
processing 2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@raymondnijssen raymondnijssen added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jan 25, 2022
@elpaso elpaso self-assigned this Jan 25, 2022
@gioman gioman added the PyQGIS Related to the PyQGIS API label Jan 25, 2022
@nyalldawson
Copy link
Collaborator

Is this a qgis bug? Looking at the sample code I suspect it's a pyqt/qt bug. Can you reproduce with a standalone pyqt script run outside of qgis?

@nyalldawson nyalldawson added the Feedback Waiting on the submitter for answers label Jan 25, 2022
@m-kuhn
Copy link
Member

m-kuhn commented Jan 25, 2022

It's a qgis bug, we are experiencing the same.

Sending data through QgsNetworkAccessManager with post and multipart fails with error 99.
The same works with QNetworkAccessManager.

QgsNetworkAccessManager (no headers printed)

from PyQt5.QtCore import *
from PyQt5.QtNetwork import *

url = QUrl('https://www.opengis.ch')
request = QNetworkRequest(url)
# request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True)
multi_part = QHttpMultiPart(QHttpMultiPart.MixedType)

reply = QgsNetworkAccessManager.instance().post(request, multi_part)
print(reply.error())
def prn():
    for header in reply.rawHeaderList():
        print(str(header))

reply.finished.connect(prn)

QNetworkAccessManager (headers print fine)

from PyQt5.QtCore import *
from PyQt5.QtNetwork import *

url = QUrl('https://www.opengis.ch')
request = QNetworkRequest(url)
# request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True)
multi_part = QHttpMultiPart(QHttpMultiPart.MixedType)

nam = QNetworkAccessManager()

reply = nam.post(request, multi_part)
print(reply.error())
def prn():
    for header in reply.rawHeaderList():
        print(str(header))

reply.finished.connect(prn)

It is connected to

content = outgoingData->readAll();
, commenting this line fixes the issue

m-kuhn added a commit to m-kuhn/QGIS that referenced this issue Jan 25, 2022
@raymondnijssen
Copy link
Contributor Author

raymondnijssen commented Jan 27, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers PyQGIS Related to the PyQGIS API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants