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

Use user:pass@ from URI in Authorization: Basic #52

Merged
merged 3 commits into from
Mar 21, 2014
Merged

Use user:pass@ from URI in Authorization: Basic #52

merged 3 commits into from
Mar 21, 2014

Conversation

crosser
Copy link
Contributor

@crosser crosser commented Mar 17, 2014

simpleHTTP allows the URI of the format "http://user:pass@host.dom/path",
but user:pass@ part is simply stripped out and ignored. This commit
introduces a 'normalizer' that takes user:pass@ data from the request's
URI and adds "Authorization: Basic ..." header to the request. This
normalizer is called before the normalizeHostURI normalizer, as the
latter strips the user:pass@ part from the URI.

Please note that I am not an experienced Haskeller, it would be best if someone knowledgeable took a look at my work. Anyway, it does work for me.

simpleHTTP allows the URI of the format "http://user:pass@host.dom/path",
but user:pass@ part is simply stripped out and ignored. This commit
introduces a 'normalizer' that takes user:pass@ data from the request's
URI and adds "Authorization: Basic ..." header to the request. This
normalizer is called before the normalizeHostURI normalizer, as the
latter strips the user:pass@ part from the URI.
@hsenag
Copy link
Member

hsenag commented Mar 19, 2014

Thanks for the patch! Do you think you could write a test for this too? The test harness is in test/httpTests.hs

@crosser
Copy link
Contributor Author

crosser commented Mar 19, 2014

Test? emm... I'm afraid I am unacquainted with Haskell's testing infrastructure. I'll see what I can do.

Incidentally, the doc probably needs an update too, I forgot about it.

@hsenag
Copy link
Member

hsenag commented Mar 19, 2014

Take a look at the existing tests and just copy the same pattern - the tests are based around firing up a local web-server that returns appropriate results for specific paths. So (roughly) you'll need to update the set of paths that it recognises with something that looks at the auth credentials, and then write a test that uses the newly supported format to retrieve that URL.

@crosser
Copy link
Contributor Author

crosser commented Mar 19, 2014

@hsenag, I wrote the testcases. The change does not look pretty, but that is because the existing URL constructors where not very flexible...

@hsenag hsenag merged commit 42e4eac into haskell:master Mar 21, 2014
@hsenag
Copy link
Member

hsenag commented Mar 21, 2014

Thanks! I'll try to get a release out with it soon.

Agreed re the URL constructors not being flexible enough for this case, I'll see about refactoring them at some point.

@hsenag
Copy link
Member

hsenag commented Mar 31, 2014

I've uploaded HTTP 4000.2.12 with this change, thanks again for the patch.

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