Skip to content

Commit 18c6623

Browse files
committed
Added urlfetch adapter
1 parent a6e8e0e commit 18c6623

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-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)

0 commit comments

Comments
 (0)