Show More
@@ -43,25 +43,6 b' class webproto(object):' | |||
|
43 | 43 | break |
|
44 | 44 | yield z.compress(chunk) |
|
45 | 45 | yield z.flush() |
|
46 | def sendresponse(self, s): | |
|
47 | self.req.respond(HTTP_OK, HGTYPE, length=len(s)) | |
|
48 | self.response = s | |
|
49 | def sendstream(self, source): | |
|
50 | self.req.respond(HTTP_OK, HGTYPE) | |
|
51 | for chunk in source.gen: | |
|
52 | self.req.write(chunk) | |
|
53 | def sendpushresponse(self, rsp): | |
|
54 | val = sys.stdout.getvalue() | |
|
55 | sys.stdout, sys.stderr = self.oldio | |
|
56 | self.req.respond(HTTP_OK, HGTYPE) | |
|
57 | self.response = '%d\n%s' % (rsp.res, val) | |
|
58 | ||
|
59 | handlers = { | |
|
60 | str: sendresponse, | |
|
61 | wireproto.streamres: sendstream, | |
|
62 | wireproto.pushres: sendpushresponse, | |
|
63 | } | |
|
64 | ||
|
65 | 46 | def _client(self): |
|
66 | 47 | return 'remote:%s:%s:%s' % ( |
|
67 | 48 | self.req.env.get('wsgi.url_scheme') or 'http', |
@@ -74,5 +55,14 b' def iscmd(cmd):' | |||
|
74 | 55 | def call(repo, req, cmd): |
|
75 | 56 | p = webproto(req) |
|
76 | 57 | rsp = wireproto.dispatch(repo, p, cmd) |
|
77 | webproto.handlers[rsp.__class__](p, rsp) | |
|
78 | return [p.response] | |
|
58 | if isinstance(rsp, str): | |
|
59 | req.respond(HTTP_OK, HGTYPE, length=len(rsp)) | |
|
60 | return [rsp] | |
|
61 | elif isinstance(rsp, wireproto.streamres): | |
|
62 | req.respond(HTTP_OK, HGTYPE) | |
|
63 | return rsp.gen | |
|
64 | elif isinstance(rsp, wireproto.pushres): | |
|
65 | val = sys.stdout.getvalue() | |
|
66 | sys.stdout, sys.stderr = p.oldio | |
|
67 | req.respond(HTTP_OK, HGTYPE) | |
|
68 | return ['%d\n%s' % (rsp.res, val)] |
General Comments 0
You need to be logged in to leave comments.
Login now