-
-
Notifications
You must be signed in to change notification settings - Fork 702
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
OPTIONS requests return a 500 error #1001
Comments
To get a traceback:
And then:
This causes the server to open a debugging prompt:
|
So the bug is in this code here: datasette/datasette/views/base.py Lines 113 to 115 in 703439b
|
What should an OPTIONS request return, anyway? |
|
The www.djangoproject.com site returns an empty page:
|
I'm tempted to imitate Django Rest Framework here: https://github.com/encode/django-rest-framework/blob/2e721cdbc85a924d0b0f093b86fe1497b58fe287/rest_framework/views.py#L514-L521 def options(self, request, *args, **kwargs):
"""
Handler method for HTTP 'OPTIONS' request.
"""
if self.metadata_class is None:
return self.http_method_not_allowed(request, *args, **kwargs)
data = self.metadata_class().determine_metadata(request, self)
return Response(data, status=status.HTTP_200_OK) That Note the comment at the top:
|
I actually have a sensible datasette/datasette/views/base.py Lines 154 to 165 in a648bb8
I'm going to set the default one to return a 405 (Method Not Allowed) like Google does. |
Closes #943 * Datasette now requires httpx>=0.15 * Support OPTIONS without 500, closes #1001 * Added internals tests for datasette.client methods * Datasette's own test mechanism now uses httpx to simulate requests * Tests simulate HTTP 1.1 now * Added base_url in a bunch more places * Mark some tests as xfail - will remove that when new httpx release ships: #1005
The text was updated successfully, but these errors were encountered: