Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
Changing sql streaming errors.
Browse files Browse the repository at this point in the history
Adding content-disposition, so clients using the web front end will see the error.
Changing the status code to 200, because at least one user-agent wouldn't show the file if it had a status of 400
  • Loading branch information
vegitron committed Jun 26, 2015
1 parent 9b648a3 commit bc275ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions sqlshare_rest/test/api/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_bad_query(self):

download_url = response["Location"]
response2 = self.client.get(download_url, content_type='application/json')
self.assertEqual(response2.status_code, 400)
self.assertEqual(response2.status_code, 200)


if is_sqlite3():
Expand All @@ -104,7 +104,7 @@ def test_bad_query(self):

download_url = response["Location"]
response2 = self.client.get(download_url, content_type='application/json')
self.assertEqual(response2.status_code, 400)
self.assertEqual(response2.status_code, 200)

def test_bad_download(self):
owner = "query_user1"
Expand Down
4 changes: 2 additions & 2 deletions sqlshare_rest/test/api/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def test_running(self):

with LogCapture() as l:
response = self.client.post(url, { "sql": "SELECT (1" }, **auth_headers)
self.assertEquals(response.status_code, 400)
self.assertEquals(response.status_code, 200)
self.assertTrue(self._has_log(l, user, None, 'sqlshare_rest.views.sql', 'INFO', 'Running SQL: SELECT (1'))


response = self.client.post(url, { }, **auth_headers)
self.assertEquals(response.status_code, 400)
self.assertEquals(response.status_code, 200)

response = self.client.post(url, { "sql": "SELECT (1), (2)" }, **auth_headers)
self.assertEquals(response.status_code, 200)
Expand Down
4 changes: 3 additions & 1 deletion sqlshare_rest/views/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def response_for_query(sql, user, download_name):
return response
except Exception as ex:
response = HttpResponse(str(ex))
response.status_code = 400
response.status_code = 200
disposition = 'attachment; filename="%s"' % download_name
response['Content-Disposition'] = disposition
return response


Expand Down

0 comments on commit bc275ba

Please sign in to comment.