[Development] Proposal for allowing handling of HTTP redirects in QNAM

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Tue Dec 24 08:57:41 CET 2013

Hi All,

Few days back I stumbled upon this task:

"QNetworkAccessManager should support redirection"

I think this is a useful feature that can be added to QNAM as it makes
the life of a developer easy.

I went through all the comments in the task page, libcurl
documentation and also saw how some other libraries, like Python's
urllib, handle redirection.

I'm collating all that info here as a proposal for new functionality
to QNAM and friends:

1. Allow handling of redirects at both global (QNAM) and per request
(QNetworkRequest) level. Per request setting overrides global setting.
Default will be to NOT handle redirects.

2. New "redirected(QUrl)" signal to be emitted in case auto-redirects
are enabled and a redirection occurs.

3. QNetworkReply stores both, the original as well as the final url.

4. Allow setting of "max redirect" to avoid infinite redirections.

5. Allow a way to specify which protocols are allowed on redirects.
Eg: curl by default does not redirect to "file" and "scp" protocols.

6. Allow a way to specify redirect behaviour for POST requests. Eg: if
a 301 is returned, the RFC states that the user agent MUST NOT change
it to a GET request automatically.

7. New error code in QNetworkReply to indicate "too many redirects" error.

The last update on this task was more than a year back. So I'm not
sure if someone's already worked on it or if it's been abandoned due
to some issue.

I was wondering if a patch for it will be acceptable?


More information about the Development mailing list