Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with Base64 encoding for basic auth #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

airsource
Copy link

Simple fix to resolve the newline encoded at the end of the basic auth string.

Symptom:

ERROR Crawled 1 urls with 1 error(s) in 0.01 seconds

  Start URL(s): http://foobar.foo

  error (<type 'exceptions.ValueError'>): Invalid header value 'Basic YWlyc291cmNlOmJsYWhibGFo\n': http://foobar.foo

Cause:

As others have reported (e.g. here there's a problem with using the encode methods for Base64 encoding as they append a newline character, which results in an invalid header. This allegedly started to occur after a security fix made to Python.

Fix:

Replace the Base64 encode method with b64encode instead - this doesn't append a newline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants