'HTTP requests to raw data'

def downstream_recv(self, data):

    try:
        d = data.peek()
        decoded_data = ''
        tab = d.split('\r\n\r\n')
        if (not d.endswith('\r\n\r\n')):
            tab = tab[:(-1)]
        for req in tab:
            try:
                if req:
                    newdata = self.http_req2data(req)
                    decoded_data += newdata
                    data.drain((len(req) + 4))
            except MalformedData as InvalidHTTPReq:
                logging.debug('invalid/malformed    data,    answering    404    and    closing    connection')
                self.downstream.write(error_response)
                self.close()
                return
            except Exception as e:
                break
        self.upstream.write(decoded_data)
    except Exception as e:
        logging.debug(e)
