Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dobisel/yhttp
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Sep 23, 2021
2 parents 153b262 + 4f5d134 commit b17f8af
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ def get(req):
assert response.text == ''


def test_modified(app, Given):

@app.route()
def get(req):
raise statuses.notmodified()

with Given():
assert status == 304
assert response.text == ''


def test_nocontent(app, Given):

@app.route()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def test_request(app, Given):
def get(req):
assert req.fullpath == 'http://bddrest-interceptor/foo?bar=baz'
assert req.scheme == 'http'
assert req.headers.get('foo') == 'bar'
assert req.headers.get('foo-bar') == 'baz'

with Given('/foo?bar=baz', headers=dict(foo='bar')):
with Given('/foo?bar=baz', headers={'Foo-Bar': 'baz'}):
assert status == 200
2 changes: 1 addition & 1 deletion yhttp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
movedpermanently, found


__version__ = '2.13.2'
__version__ = '2.13.4'
2 changes: 1 addition & 1 deletion yhttp/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(self, environ):

@staticmethod
def getkey(k):
return f'HTTP_{k.upper()}'
return f'HTTP_{k.replace("-", "_").upper()}'

def __getitem__(self, key):
return self.environ[self.getkey(key)]
Expand Down
2 changes: 1 addition & 1 deletion yhttp/statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def setupresponse(self, response, stacktrace=False):
preconditionfailed = partial(status, 412, 'Precondition Failed')

#: HTTP 304 Not Modified exception factory
notmodified = partial(status, 304, 'Not Modified')
notmodified = partial(status, 304, 'Not Modified', nobody=True)

#: HTTP 500 Internal Server Error exception factory
internalservererror = partial(status, 500, 'Internal Server Error')
Expand Down

0 comments on commit b17f8af

Please sign in to comment.