PageRenderTime 121ms CodeModel.GetById 70ms app.highlight 2ms RepoModel.GetById 28ms app.codeStats 20ms

/examples/jsonrpc/public/services/jsonrpc/http.py

http://pyjamas.googlecode.com/
Python | 34 lines | 12 code | 3 blank | 19 comment | 0 complexity | 258fea72316378cb400f25908cfcca4a MD5 | raw file
 1"""
 2  Copyright (c) 2006 Jan-Klaas Kollhof
 3
 4  This file is part of jsonrpc.
 5
 6  jsonrpc is free software; you can redistribute it and/or modify
 7  it under the terms of the GNU Lesser General Public License as published by
 8  the Free Software Foundation; either version 2.1 of the License, or
 9  (at your option) any later version.
10
11  This software is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU Lesser General Public License for more details.
15
16  You should have received a copy of the GNU Lesser General Public License
17  along with this software; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
19"""
20
21from jsonrpc import SimpleServiceHandler
22import urllib2
23
24
25class HTTPClientConnectionHandler(SimpleServiceHandler):
26    def __init__(self, url, service,messageDelimiter=""):
27        self.url = url
28        SimpleServiceHandler.__init__(self, service,messageDelimiter=messageDelimiter)
29        
30    def send(self, data):
31        req = urllib2.Request(self.url, data)
32        resp = urllib2.urlopen(req)
33        self.handlePartialData(resp.read())
34