[Interest] QNetworkAccessManager put uploads contents twice

ashish dabhade ashishd157 at gmail.com
Tue Dec 1 07:53:58 CET 2015


Thiago, thanks for the tip. I did it by the first way by pre-authenticating
before actually sending the file. For that I'm just requesting the headers
through **head**. It works now as expected. Thanks again for the other
useful info.

On Tue, Dec 1, 2015 at 11:39 AM, Thiago Macieira <thiago.macieira at intel.com>
wrote:

> On Tuesday 01 December 2015 11:30:32 ashish dabhade wrote:
> > To avoid that I also tested it by removing the authenticationRequired and
> > passing username and password in the url as per basic auth specs. For eg.
> > QUrl( "http://user:password@192.168.1.157/webdav/Media/somefile.mp4" ).
> > This too resulted the same behavior.
>
> QNetworkAccessManager needs to know which authentication method to use. It
> can
> only get that information after trying the server first.
>
> Try this: get, post or put something else in the same server, so you're
> authenticated. I'm not sure if this works, but we can call this a missing
> feature if it doesn't.
>
> > Also suppose the file is of large size say for eg. 300 Mb. wouldn't it be
> > unnecessary to upload so much data twice ?
>
> It's a limitation of the HTTP protocol. QNAM can use the
>
>         Expects: 100
>
> header and the server MAY reply with an error message before the end of the
> upload. But it's not a guarantee that it will, so QNAM has to try and
> upload
> everything.
>
> If you don't like this, try using a different protocol.
>
> > I tested the same scenario with the now deprecated **QHttp** class and to
> > the surprise it uploaded the contents just once.
>
> If you don't try something first, QHttp will use Basic authentication,
> which is
> not secure (the password is sent in the clear). QNAM doesn't allow that:
> you
> need to get the authentication mechanisms first so that it will try the
> most
> secure option.
>
> > So if the above scenario is due to the design what would be the best way
> to
> > handle it ? For smaller files it is fine. I wanted to show the progress
> bar
> > for uploading which now fills up twice :)
>
> See above for two alternatives.
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151201/a2413db0/attachment.html>


More information about the Interest mailing list