From 10edd9492022a24ca1e9713edbb6a04f1de5875c Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Tue, 17 Nov 2020 09:18:40 -0500 Subject: [PATCH] Vanguard client: Accept 500 errors on initial response Though their server returns a 500 HTTP status code, it still sets the required cookies on the response that we can use to make a second request. --- basic_client.go | 2 +- vanguard_client.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/basic_client.go b/basic_client.go index 4abaf21..c327ae5 100644 --- a/basic_client.go +++ b/basic_client.go @@ -74,7 +74,7 @@ func (c *BasicClient) RawRequest(URL string, r io.Reader) (*http.Response, error } if response.StatusCode != 200 { - return nil, errors.New("OFXQuery request status: " + response.Status) + return response, errors.New("OFXQuery request status: " + response.Status) } return response, nil diff --git a/vanguard_client.go b/vanguard_client.go index 4728d5f..e367259 100644 --- a/vanguard_client.go +++ b/vanguard_client.go @@ -64,7 +64,7 @@ func (c *VanguardClient) RequestNoParse(r *Request) (*http.Response, error) { // Fortunately, the initial response contains the cookie we need, so if we // detect an empty response with cookies set that didn't have any errors, // re-try the request while sending their cookies back to them. - if err == nil && response.ContentLength <= 0 && len(response.Cookies()) > 0 { + if response != nil && response.ContentLength <= 0 && len(response.Cookies()) > 0 { b, err = r.Marshal() if err != nil { return nil, err