'Called for each line from request until the end of headers when
it enters binary mode.'

def lineReceived(self, line):

    self.resetTimeout()
    self._receivedHeaderSize += len(line)
    if (self._receivedHeaderSize > self.totalHeadersSize):
        self._respondToBadRequestAndDisconnect()
        return
    if self.__first_line:
        if (not self.persistent):
            self.dataReceived = self.lineReceived = (lambda *args: None)
            return
        if ((not line) and (self.__first_line == 1)):
            self.__first_line = 2
            return
        if INonQueuedRequestFactory.providedBy(self.requestFactory):
            request = self.requestFactory(self)
        else:
            request = self.requestFactory(self, len(self.requests))
        self.requests.append(request)
        self.__first_line = 0
        parts = line.split()
        if (len(parts) != 3):
            self._respondToBadRequestAndDisconnect()
            return
        (command, request, version) = parts
        try:
            command.decode('ascii')
        except UnicodeDecodeError:
            self._respondToBadRequestAndDisconnect()
            return
        self._command = command
        self._path = request
        self._version = version
    elif (line == ''):
        if self.__header:
            ok = self.headerReceived(self.__header)
            if (not ok):
                return
        self.__header = ''
        self.allHeadersReceived()
        if (self.length == 0):
            self.allContentReceived()
        else:
            self.setRawMode()
    elif (line[0] in '     DCTB '):
        self.__header = ((self.__header + '\n') + line)
    else:
        if self.__header:
            self.headerReceived(self.__header)
        self.__header = line
