/site-packages/django/http/request.py in body
line 267
{{{
#!python
# request.META['CONTENT_LENGTH'] = ''
int(self.META.get('CONTENT_LENGTH', 0)) >
settings.DATA_UPLOAD_MAX_MEMORY_SIZE):
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27005>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Hi,
Thanks for reporting this issue to us.
Could you provide some information on how you managed to trigger this
error? A full traceback would also be helpful.
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:1>
Comment (by dvinegla):
{{{
Environment:
Request Method: GET
Request URL: http://localhost:8000/myapp/
Django Version: 1.10
Python Version: 2.7.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "./python2.7/site-packages/django/core/handlers/exception.py" in
inner
39. response = get_response(request)
File "./python2.7/site-packages/django/core/handlers/base.py" in
_get_response
187. response = self.process_exception_by_middleware(e,
request)
File "./python2.7/site-packages/django/core/handlers/base.py" in
_get_response
185. response = wrapped_callback(request,
*callback_args, **callback_kwargs)
File "/testproject/myapp/views.py" in test_view
7. assert False, request.body
File "./python2.7/site-packages/django/http/request.py" in body
267. int(self.META.get('CONTENT_LENGTH', 0)) >
settings.DATA_UPLOAD_MAX_MEMORY_SIZE):
Exception Type: ValueError at /myapp/
Exception Value: invalid literal for int() with base 10: ''
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:2>
Comment (by dvinegla):
https://github.com/django/django/commit/929684d6ee0efb5afad51dc584489d0437d2451b
#diff-0eb6c5000a61126731553169fddb306eR267
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:3>
Comment (by bmispelon):
Could you also show us what `testproject.myapp.views.test_view` looks
like?
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:4>
Comment (by dvinegla):
{{{
from django.shortcuts import render
# Create your views here.
def test_view(request):
assert False, request.body
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:5>
Comment (by dvinegla):
{{{#!python
# testproject/testproject/urls.py
"""testproject URL Configuration
The `urlpatterns` list routes URLs to views. For more information please
see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url,
include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^myapp/', include('myapp.urls')),
url(r'^admin/', admin.site.urls),
]
}}}
{{{#!python
# testproject/myapp/urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.test_view),
]
}}}
{{{#!python
# testproject/myapp/views.py
from django.shortcuts import render
# Create your views here.
def test_view(request):
assert False, request.body
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:6>
* component: Uncategorized => HTTP handling
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:7>
Comment (by bmispelon):
If it helps, here's a small testcase that reproduces the issue (it works
on 1.9 but fails on 1.10):
{{{#!python
from django.test import TestCase, RequestFactory
class ReproTestCase(TestCase):
def test_repro(self):
request = RequestFactory().get('/', CONTENT_LENGTH='')
self.assertEqual(request.META['CONTENT_LENGTH'], '')
self.assertFalse(request.body)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:8>
* status: new => assigned
* owner: nobody => timgraham
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:9>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/7016 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:10>
* stage: Accepted => Ready for checkin
Comment:
Looks good to me, thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:11>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"5c63b3e5a797102d915e1683971517f747a28013" 5c63b3e5]:
{{{
#!CommitTicketReference repository=""
revision="5c63b3e5a797102d915e1683971517f747a28013"
Fixed #27005 -- Fixed crash if request.META[''CONTENT_LENGTH']=''.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:12>
Comment (by Tim Graham <timograham@…>):
In [changeset:"dcebeea2703322bc53c511bf3cff9e3c2e04d802" dcebeea]:
{{{
#!CommitTicketReference repository=""
revision="dcebeea2703322bc53c511bf3cff9e3c2e04d802"
[1.10.x] Fixed #27005 -- Fixed crash if
request.META[''CONTENT_LENGTH']=''.
Backport of 5c63b3e5a797102d915e1683971517f747a28013 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:13>