Django Status 200 but 'Failed to Load Response Data" On Certain Image Uploads

Question:

I’m making an ajax post request to the Python Django view below which always return a success json response.

# views.py
@csrf_exempt
def success_response(request):
    """
    Returns a http response with a JSON success state
    :param request: 
    :return: 
    """
    return JsonResponse({'success': True})

In each ajax post request, i’m attaching an image file in enctype=multipart/form-data format. As you can see, here is an example request payload:

------WebKitFormBoundarymYCuLcqA6kEkqMA7
Content-Disposition: form-data; name="file"; filename="willprobablycrash.png"
Content-Type: image/png


------WebKitFormBoundarymYCuLcqA6kEkqMA7--

How is it possible that images below a certain image dimension (below 960px x 1141px) return the intended response {"success": true} while images above the said dimension return Failed to Load Response Data?

In both success and error cases, the status_code in the response is 200.

Asked By: clodal

||

Answers:

Surprisingly, it is possible for http to return status_code 200 while failing to load the response data. Which resulted in the error i had above: Failed to Load Response Data. In this case, it was my server core code (Django) being able to send the response but there was no data included due to some issues with the resolvers within the framework. After i fixed those issues, i could receive 200 + the response data that i needed.

Answered By: clodal

It because of Advertising blocker chrome extensions on your browser

Answered By: InternetWarrior
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.