view hgext/inotify/common.py @ 6379:d2bb66a8a435

hgweb: add compatibility code for old templates Up to changeset 3340aa5a64f7, HTTP headers were expected to be embedded in the "headers" template. Since that changeset, the content-type is supposed to be defined as the "mimetype" template in the map file. This changeset makes sure the old templates still work.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 24 Mar 2008 13:45:01 -0300
parents 39cfcef4f463
children 46293a0c7e9f
line wrap: on
line source

# server.py - inotify common protocol code
#
# Copyright 2006, 2007, 2008 Bryan O'Sullivan <bos@serpentine.com>
# Copyright 2007, 2008 Brendan Cully <brendan@kublai.com>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.

import cStringIO, socket, struct

version = 1

resphdrfmt = '>llllllll'
resphdrsize = struct.calcsize(resphdrfmt)

def recvcs(sock):
    cs = cStringIO.StringIO()
    s = True
    try:
        while s:
            s = sock.recv(65536)
            cs.write(s)
    finally:
        sock.shutdown(socket.SHUT_RD)
    cs.seek(0)
    return cs