Fix various aspects of dispatching webhook with auth credentials

Review Request #11171 — Created Sept. 14, 2020 and discarded — Latest diff uploaded

Information

Review Board
master

Reviewers

Fix error dispatching webhook with auth credentials

The error was:

AttributeError: 'SplitResult' object has no attribute 'params'

The 5-tuple used for rebuilding the URL was missing the fragment element instead.


Log webhook server responses on error

If the exception from urlopen represents an HTTP response, then the included
information may be useful to the site admin in troubleshooting.


Always send Authorization header on authenticated webhooks

The problem with HTTPBasicAuthHandler is that it will first attempt to make an
unauthenticated request, and will retry with authentication only if a 401
response was seen. However, some servers respond with 403 if the right
credentials are not supplied right away.

This is a forward-ported version of my patches on top of 3.0.18, which is powering our production site.

Note: It is best to review the changes one commit at a time. The patch series is available publicly on Github.