How to handle correctly HTTP Digest Authentication on iPhone

Posted by Fabiano Francesconi on Stack Overflow See other posts from Stack Overflow or by Fabiano Francesconi
Published on 2010-05-13T13:46:36Z Indexed on 2010/05/13 15:44 UTC
Read the original article Hit count: 616

Filed under:
|
|
|
|

Hello guys. I'm trying to upload a file onto my personal server.

I've written a small php page that works flawlessy so far.

The little weird thing is the fact that I generate all the body of the HTTP message I'm going to send (let's say that amounts to ~4 mb) and then I send the request to my server.

The server, then, asks for an HTTP challenge and my delegate connection:didReceiveAuthenticationChallenge:challenge replies to the server with the proper credentials and the data.

But, what's happened? The data has been sent twice!

In fact I've noticed that when I added the progressbar.. the apps sends the data (4mb), the server asks for authentication, the apps re-sends the data with the authentication (another 4mb). So, at the end, I've sent 8mb. That's wrong.

I started googling and searching for a solution but I can't figure out how to fix this.

The case scenarios are two (my guess):

  • Share the realm for the whole session (a minimal HTTP request, then challenge, then data)
  • Use the synchronized way to perform an HTTP connection (things that I do not want to do since it seems an ugly way to handle this kind of stuff to me)

Thank you

© Stack Overflow or respective owner

Related posts about iphone

Related posts about SDK