Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
fb0ee690
Commit
fb0ee690
authored
Aug 19, 2014
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning up a few quality violations
parent
7bb2535d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
common/djangoapps/contentserver/middleware.py
+6
-4
common/djangoapps/contentserver/tests/test.py
+10
-4
No files found.
common/djangoapps/contentserver/middleware.py
View file @
fb0ee690
from
django.http
import
(
HttpResponse
,
HttpResponseNotModified
,
HttpResponseForbidden
)
from
django.http
import
(
HttpResponse
,
HttpResponseNotModified
,
HttpResponseForbidden
)
from
student.models
import
CourseEnrollment
from
xmodule.contentstore.django
import
contentstore
...
...
@@ -13,6 +14,7 @@ from xmodule.exceptions import NotFoundError
# TODO: Soon as we have a reasonable way to serialize/deserialize AssetKeys, we need
# to change this file so instead of using course_id_partial, we're just using asset keys
class
StaticContentServer
(
object
):
def
process_request
(
self
,
request
):
# look to see if the request is prefixed with an asset prefix tag
...
...
@@ -113,11 +115,11 @@ class StaticContentServer(object):
first
=
first
,
last
=
last
,
length
=
content
.
length
)
response
[
'Content-Length'
]
=
str
(
last
-
first
+
1
)
response
.
status_code
=
206
# HTTP_206_PARTIAL_CONTENT
response
.
status_code
=
206
# HTTP_206_PARTIAL_CONTENT
if
not
response
:
# Malformed Range attribute
response
=
HttpResponse
()
response
.
status_code
=
400
# HTTP_400_BAD_REQUEST
response
.
status_code
=
400
# HTTP_400_BAD_REQUEST
return
response
else
:
...
...
common/djangoapps/contentserver/tests/test.py
View file @
fb0ee690
...
...
@@ -42,8 +42,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2012_Fall'
)
import_from_xml
(
modulestore
(),
self
.
user
.
id
,
'common/test/data/'
,
[
'toy'
],
static_content_store
=
self
.
contentstore
,
verbose
=
True
)
import_from_xml
(
modulestore
(),
self
.
user
.
id
,
'common/test/data/'
,
[
'toy'
],
static_content_store
=
self
.
contentstore
,
verbose
=
True
)
# A locked asset
self
.
locked_asset
=
self
.
course_key
.
make_asset_key
(
'asset'
,
'sample_static.txt'
)
...
...
@@ -109,8 +111,12 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
resp
=
self
.
client
.
get
(
self
.
url_unlocked
,
HTTP_RANGE
=
'bytes=0-'
)
self
.
assertEqual
(
resp
.
status_code
,
206
)
# HTTP_206_PARTIAL_CONTENT
self
.
assertEqual
(
resp
[
'Content-Range'
],
'bytes {first}-{last}/{length}'
.
format
(
first
=
0
,
last
=
self
.
length_unlocked
-
1
,
length
=
self
.
length_unlocked
)
self
.
assertEqual
(
resp
[
'Content-Range'
],
'bytes {first}-{last}/{length}'
.
format
(
first
=
0
,
last
=
self
.
length_unlocked
-
1
,
length
=
self
.
length_unlocked
)
)
self
.
assertEqual
(
resp
[
'Content-Length'
],
str
(
self
.
length_unlocked
))
...
...
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