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

Fixes #46 - Vanguard fix #47

Merged
merged 3 commits into from
Jan 8, 2018
Merged

Conversation

jantman
Copy link
Contributor

@jantman jantman commented Jul 31, 2017

Fixes #46 - Vanguard download problems

This provides a fix for the Vanguard downloading problems. It may also fix other banks that decide to follow the same pattern...

I found that PocketSense users were having the same problem with Vanguard. That application's developer determined that Vanguard now requires cookie handling; the original request to Vanguard returns a HTTP 200 with a 0-length body, but a number of Set-Cookie headers. Re-sending the request with the appropriate Cookie headers returns the proper OFX.

This PR includes:

  1. Minor refactor to the HTTP header sending logic in Client.post() so it builds a list of headers and then puts them all at once, logging the headers as it does. Previously, the request body (query) was logged at debug level but the headers were not, and headers appear to be more problematic lately.
  2. Rename the Client.post() method to Client._do_post() and create a new Client.post() wrapper method. This wrapper calls .post() and if (and only if) the response has 0 length, an HTTP 200 return code, and one or more Set-Cookie headers present, it retries the request with the proper Cookie header set and returns that response.

I've tested this just now and it works properly to fix the Vanguard problem, and also works with American Express, Citi Cards, Discover and TIAA-CREF.

jantman added 3 commits July 31, 2017 18:43
- Rename Client.post() to Client._do_post() and wrap with a new Client.post() method
- If the POST returns a 0-length response with a HTTP 200 status code and Set-Cookie header(s), retry with appropriate Cookie headers and return that response
jantman added a commit to jantman/biweeklybudget that referenced this pull request Aug 7, 2017
@captin411 captin411 merged commit 83a6018 into captin411:master Jan 8, 2018
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.

Cannot download from Vanguard
2 participants