Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
just return blank http responses for api calls (bug 816120)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy McKay committed Nov 28, 2012
1 parent 46cb27e commit a955d45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions mkt/site/tests/test_views.py
Expand Up @@ -66,6 +66,11 @@ def test_404_consumer(self):
password='password')
self._test_404('/xxx')

def test_404_api(self):
res = self.client.get('/api/this-should-never-work/')
eq_(res.status_code, 404)
eq_(res.content, '')


class TestManifest(amo.tests.TestCase):

Expand Down
8 changes: 4 additions & 4 deletions mkt/site/views.py
Expand Up @@ -5,7 +5,8 @@

from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.http import (HttpResponse, HttpResponseNotFound,
HttpResponseServerError)
from django.template import RequestContext
from django.views.decorators.cache import cache_page
from django.views.decorators.csrf import csrf_exempt, requires_csrf_token
Expand All @@ -21,7 +22,6 @@
from amo.decorators import post_required, no_login_required
from amo.helpers import media
from amo.urlresolvers import reverse
import api.views


log = logging.getLogger('z.mkt.site')
Expand All @@ -43,15 +43,15 @@ def handler403(request):
def handler404(request):
if request.path_info.startswith('/api/'):
# Pass over to API handler404 view if API was targeted.
return api.views.handler404(request)
return HttpResponseNotFound()
else:
return jingo.render(request, 'site/404.html', status=404)


def handler500(request):
if request.path_info.startswith('/api/'):
# Pass over to API handler500 view if API was targeted.
return api.views.handler500(request)
return HttpResponseServerError()
else:
return jingo.render(request, 'site/500.html', status=500)

Expand Down

0 comments on commit a955d45

Please sign in to comment.