From e275b861fc42a3597dd8e0469f7b70a9aeb0026b Mon Sep 17 00:00:00 2001 From: Chetanya Kandhari Date: Fri, 5 Apr 2019 12:09:27 +0530 Subject: [PATCH 1/4] Check for response status in Client.Store() method --- client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client.go b/client.go index 0fc4ba9..30eb636 100644 --- a/client.go +++ b/client.go @@ -110,6 +110,10 @@ func (c *Client) Store(req Request, dest string) error { if err != nil { return err } + // Check for 2XX Status Codes + if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices { + return errors.New("cannot convert file to PDF") + } return writeNewFile(dest, resp.Body) } From 2121b47795187dee7c67f60f7baec88d3fdaf777 Mon Sep 17 00:00:00 2001 From: Chetanya Kandhari Date: Wed, 10 Apr 2019 16:56:35 +0530 Subject: [PATCH 2/4] Update error message --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 30eb636..d316e3c 100644 --- a/client.go +++ b/client.go @@ -112,7 +112,7 @@ func (c *Client) Store(req Request, dest string) error { } // Check for 2XX Status Codes if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices { - return errors.New("cannot convert file to PDF") + return errors.New("failed to generate the result PDF") } return writeNewFile(dest, resp.Body) } From 51708952a3e880338cc2e6b686d231f0a802f32c Mon Sep 17 00:00:00 2001 From: Chetanya Kandhari Date: Wed, 9 Oct 2019 00:53:47 +0530 Subject: [PATCH 3/4] Fix go fmt --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 99db0c4..387d869 100644 --- a/client.go +++ b/client.go @@ -95,7 +95,7 @@ func (c *Client) Store(req Request, dest string) error { } defer resp.Body.Close() - // Check for 2XX Status Codes + // Check for 2XX Status Codes if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices { return errors.New("failed to generate the result PDF") } From 6e3fdda7318904d438cbbe8b100f920403792119 Mon Sep 17 00:00:00 2001 From: Chetanya Kandhari Date: Wed, 9 Oct 2019 22:30:49 +0530 Subject: [PATCH 4/4] Update StatusCode check --- client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client.go b/client.go index 387d869..b3e1658 100644 --- a/client.go +++ b/client.go @@ -95,8 +95,7 @@ func (c *Client) Store(req Request, dest string) error { } defer resp.Body.Close() - // Check for 2XX Status Codes - if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices { + if resp.StatusCode != http.StatusOK { return errors.New("failed to generate the result PDF") } return writeNewFile(dest, resp.Body)