Subject: bug#10478: 24.0.50; url-http-parse-headers can silently drop the response when handling BASIC AUTHENTICATION

From: David Engster <[email-masked]>
Date: Sat, 03 Jun 2017 12:41:47 +0200

Lars Ingebrigtsen writes:
> Jerry Asher <[email-masked]> writes:
>
>> When making a GET request again their simplest api, users/me that
>> returns information about the logged in user, url-retrieve-synchronously
>> will return the wrong buffer.
>>
>> This seems to be traceable to url-http-parse-headers handling the "401
>> Basic: Access denied message by" calling url-http-handle-authentication
>> which prompts the user for a name and password and calls
>> url-retrieve-internal to retry the request.
>
> I can confirm that this bug is still present in Emacs 25.  It returns
> the buffer with the 401 message, not the buffer with the response...

I just stumpled upon this. Oh my, this stuff is straight from callback
hell. Lars, how's your 'url' rewrite going...?

I stared at this for hours, but was unable to come up with anything
better than what Jerry has suggested. So if nobody objects, I'd like to
commit this.

Jerry, do you have papers with the FSF signed? I'm not sure if the
resulting patch will fit in the 'trivial patch' category.

-David