Changeset 324 for py-tcpmultiplexer


Ignore:
Timestamp:
Jul 19, 2011, 10:22:19 PM (13 years ago)
Author:
Rick van der Zwet
Message:

Be smarter about the datasize

File:
1 edited

Legend:

Unmodified
Added
Removed
  • py-tcpmultiplexer/TCPMultiplexer.py

    r323 r324  
    135135        dataheader[urlid] = f.read(44)
    136136      elif datatype == 'mjpeg':
    137         data  = f.read(1024 * 1024)
    138 
    139         # Get the required headers
     137        data  = f.read(1024)
     138
     139        # Get the required headers and acurate datasize
    140140        headers = []
     141        datasize = 1024 * 1024
    141142        for header in data.splitlines():
    142143          if not header.strip():
     
    146147            else:
    147148              continue
     149          if header.startswith('DataLen:') or header.startswith('Content-length:'):
     150            datasize = int(header.split(':')[1])
    148151          headers.append(header)
    149152        boundry = headers[0]
     153
     154        logger.info("Data Length: %s", datasize)
    150155        logger.info("Boundry line: %s", boundry)
    151156        logger.info("Image headers %s", headers)
    152157
     158        data = data + f.read(datasize * 2)
    153159        valid_image = boundry + data.split(boundry)[1]
    154160        dataheader[urlid] = valid_image + '\n'.join(headers) + '\n'
Note: See TracChangeset for help on using the changeset viewer.