Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

Commit

Permalink
Mild refactor of serialization, add cache-control options
Browse files Browse the repository at this point in the history
- Rearrange methods
- Move implied serialization in `process_response` to standalone method
- Add `response_cache_control` for adding Cache-Control headers
  • Loading branch information
bruth committed Aug 3, 2012
1 parent b4895d6 commit dc7d0ee
Show file tree
Hide file tree
Showing 4 changed files with 359 additions and 246 deletions.
26 changes: 13 additions & 13 deletions restlib2/http.py → restlib2/http/__init__.py
Original file line number Original file line Diff line number Diff line change
@@ -1,17 +1,5 @@
from django.core.handlers.wsgi import STATUS_CODE_TEXT from django.core.handlers.wsgi import STATUS_CODE_TEXT
from .structures import AttrDict from restlib2.structures import AttrDict

# PATCH Method introduced - http://tools.ietf.org/html/rfc5789
methods = AttrDict('HTTP Methods',
GET = 'GET',
HEAD = 'HEAD',
OPTIONS = 'OPTIONS',
POST = 'POST',
PUT = 'PUT',
DELETE = 'DELETE',
PATCH = 'PATCH',
)



# New codes - http://tools.ietf.org/html/draft-nottingham-http-new-status-04 # New codes - http://tools.ietf.org/html/draft-nottingham-http-new-status-04
STATUS_CODE_TEXT.setdefault(422, 'UNPROCESSABLE ENTITY') STATUS_CODE_TEXT.setdefault(422, 'UNPROCESSABLE ENTITY')
Expand All @@ -24,3 +12,15 @@
codes = AttrDict('HTTP Status Codes', [ codes = AttrDict('HTTP Status Codes', [
(y.lower().replace(' ', '_'), x) for x, y in STATUS_CODE_TEXT.items() (y.lower().replace(' ', '_'), x) for x, y in STATUS_CODE_TEXT.items()
]) ])


# PATCH Method introduced - http://tools.ietf.org/html/rfc5789
methods = AttrDict('HTTP Methods',
GET = 'GET',
HEAD = 'HEAD',
OPTIONS = 'OPTIONS',
POST = 'POST',
PUT = 'PUT',
DELETE = 'DELETE',
PATCH = 'PATCH',
)
Loading

0 comments on commit dc7d0ee

Please sign in to comment.