Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
58d555ca
Kaydet (Commit)
58d555ca
authored
Eki 08, 2013
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #16822 -- Added RawPostDataException
Thanks jaylett for the patch.
üst
ddb53856
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
+16
-6
__init__.py
django/http/__init__.py
+2
-2
request.py
django/http/request.py
+10
-1
tests.py
tests/requests/tests.py
+4
-3
No files found.
django/http/__init__.py
Dosyayı görüntüle @
58d555ca
from
django.http.cookie
import
SimpleCookie
,
parse_cookie
from
django.http.request
import
(
HttpRequest
,
QueryDict
,
UnreadablePostError
,
build_request_repr
)
from
django.http.request
import
(
HttpRequest
,
QueryDict
,
RawPostDataException
,
UnreadablePostError
,
build_request_repr
)
from
django.http.response
import
(
HttpResponse
,
StreamingHttpResponse
,
HttpResponseRedirect
,
HttpResponsePermanentRedirect
,
HttpResponseNotModified
,
HttpResponseBadRequest
,
HttpResponseForbidden
,
...
...
django/http/request.py
Dosyayı görüntüle @
58d555ca
...
...
@@ -31,6 +31,15 @@ class UnreadablePostError(IOError):
pass
class
RawPostDataException
(
Exception
):
"""
You cannot access raw_post_data from a request that has
multipart/* POST data if it has been accessed via POST,
FILES, etc..
"""
pass
class
HttpRequest
(
object
):
"""A basic HTTP request."""
...
...
@@ -192,7 +201,7 @@ class HttpRequest(object):
def
body
(
self
):
if
not
hasattr
(
self
,
'_body'
):
if
self
.
_read_started
:
raise
Exception
(
"You cannot access body after reading from request's data stream"
)
raise
RawPostData
Exception
(
"You cannot access body after reading from request's data stream"
)
try
:
self
.
_body
=
self
.
read
()
except
IOError
as
e
:
...
...
tests/requests/tests.py
Dosyayı görüntüle @
58d555ca
...
...
@@ -12,7 +12,8 @@ from django.db import connection, connections, DEFAULT_DB_ALIAS
from
django.core
import
signals
from
django.core.exceptions
import
SuspiciousOperation
from
django.core.handlers.wsgi
import
WSGIRequest
,
LimitedStream
from
django.http
import
HttpRequest
,
HttpResponse
,
parse_cookie
,
build_request_repr
,
UnreadablePostError
from
django.http
import
(
HttpRequest
,
HttpResponse
,
parse_cookie
,
build_request_repr
,
UnreadablePostError
,
RawPostDataException
)
from
django.test
import
SimpleTestCase
,
TransactionTestCase
from
django.test.client
import
FakePayload
from
django.test.utils
import
override_settings
,
str_prefix
...
...
@@ -263,7 +264,7 @@ class RequestsTests(SimpleTestCase):
'CONTENT_LENGTH'
:
len
(
payload
),
'wsgi.input'
:
payload
})
self
.
assertEqual
(
request
.
read
(
2
),
b
'na'
)
self
.
assertRaises
(
Exception
,
lambda
:
request
.
body
)
self
.
assertRaises
(
RawPostData
Exception
,
lambda
:
request
.
body
)
self
.
assertEqual
(
request
.
POST
,
{})
def
test_non_ascii_POST
(
self
):
...
...
@@ -308,7 +309,7 @@ class RequestsTests(SimpleTestCase):
'CONTENT_LENGTH'
:
len
(
payload
),
'wsgi.input'
:
payload
})
self
.
assertEqual
(
request
.
POST
,
{
'name'
:
[
'value'
]})
self
.
assertRaises
(
Exception
,
lambda
:
request
.
body
)
self
.
assertRaises
(
RawPostData
Exception
,
lambda
:
request
.
body
)
def
test_body_after_POST_multipart_related
(
self
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment