Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
fb0ee690
Commit
fb0ee690
authored
10 years ago
by
David Baumgold
Browse files
Options
Downloads
Patches
Plain Diff
Cleaning up a few quality violations
parent
7bb2535d
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/djangoapps/contentserver/middleware.py
+6
-4
6 additions, 4 deletions
common/djangoapps/contentserver/middleware.py
common/djangoapps/contentserver/tests/test.py
+10
-4
10 additions, 4 deletions
common/djangoapps/contentserver/tests/test.py
with
16 additions
and
8 deletions
common/djangoapps/contentserver/middleware.py
+
6
−
4
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
:
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/contentserver/tests/test.py
+
10
−
4
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
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment