Skip to content

Commit 11363bc

Browse files
committed
Added urlfetch adapter
1 parent a6e8e0e commit 11363bc

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

pusher/urlfetch.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from __future__ import (print_function, unicode_literals, absolute_import,
4+
division)
5+
6+
import urlfetch
7+
import json
8+
from pusher.http import process_response
9+
10+
class URLFetchBackend(object):
11+
"""Adapter for the URLFetch Module. Necessary for using this library with Google
12+
App Engine"""
13+
14+
def __init__(self, config, **options):
15+
self.config = config
16+
self.options = options
17+
18+
def send_request(self, request):
19+
resp = urlfetch.fetch(
20+
url=request.url,
21+
headers=request.headers,
22+
method=request.method,
23+
data=request.body,
24+
deadline=self.config.timeout,
25+
**self.options
26+
)
27+
return process_response(resp.status_code, resp.content)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
extras_require={
2828
'aiohttp': ["aiohttp>=0.9.0"],
2929
'tornado': ['tornado>=4.0.0'],
30+
'urlfetch': ['urlfetch>=1.0']
3031
},
3132

3233
test_suite='pusher_tests',

0 commit comments

Comments
 (0)