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

Commit

Permalink
regression
Browse files Browse the repository at this point in the history
  • Loading branch information
lsbardel committed May 11, 2016
1 parent 5256dc9 commit cccc844
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
6 changes: 3 additions & 3 deletions docs/source/apps/http.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ Posting data is as simple as passing the ``data`` parameter::
Cookie support
================

Cookies are handled by sessions by storing cookies received with responses.
To disable cookie one can pass ``store_cookies=False`` during
:class:`HttpClient` initialisation.
Cookies are handled by storing cookies received with responses in a sessions
object. To disable cookie one can pass ``store_cookies=False`` during
:class:`.HttpClient` initialisation.

If a response contains some Cookies, you can get quick access to them::

Expand Down
22 changes: 5 additions & 17 deletions examples/httpbin/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import os
import sys
import string
import mimetypes
from functools import partial
from itertools import repeat, chain
from random import random
Expand All @@ -47,23 +46,12 @@
characters = string.ascii_letters + string.digits


def asset(name, mode='r', chunk_size=None):
def asset(name, mode='r'):
name = os.path.join(ASSET_DIR, name)
if os.path.isfile(name):
content_type, encoding = mimetypes.guess_type(name)
if chunk_size:
def _chunks():
with open(name, mode) as file:
while True:
data = file.read(chunk_size)
if not data:
break
yield data
data = _chunks()
else:
with open(name, mode) as file:
data = file.read()
return data, content_type, encoding
with open(name, mode) as file:
data = file.read()
return data


class BaseRouter(wsgi.Router):
Expand Down Expand Up @@ -135,7 +123,7 @@ def get(self, request):
html.head.links.append('favicon.ico', rel="icon", type='image/x-icon')
html.head.scripts.append('httpbin.js')
ul = ul.render(request)
templ, _, _ = asset('template.html')
templ = asset('template.html')
body = templ % (title, JAPANESE, CHINESE, version, pyversion, ul)
html.body.append(body)
return html.http_response(request)
Expand Down
2 changes: 1 addition & 1 deletion pulsar/apps/http/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def websocket_key(self):
@noerror
def __call__(self, response, exc=None):
request = response.request
if request and request.scheme in ('ws', 'wss'):
if request and urlparse(request.url).scheme in ('ws', 'wss'):
headers = request.headers
headers['connection'] = 'Upgrade'
headers['upgrade'] = 'websocket'
Expand Down

0 comments on commit cccc844

Please sign in to comment.