'Format this L{Request} as an HTTP/1.1 request and write it to the given
transport.  If bodyProducer is not None, it will be associated with an
L{IConsumer}.
@param transport: The transport to which to write.
@type transport: L{twisted.internet.interfaces.ITransport} provider
@return: A L{Deferred} which fires with L{None} when the request has
been completely written to the transport or with a L{Failure} if
there is any problem generating the request bytes.'

def writeTo(self, transport):

    if (self.bodyProducer is None):
        if (self.method in ('PUT', 'POST')):
            self._writeToEmptyBodyContentLength(transport)
        else:
            self._writeHeaders(transport, None)
    elif (self.bodyProducer.length is UNKNOWN_LENGTH):
        return self._writeToBodyProducerChunked(transport)
    else:
        return self._writeToBodyProducerContentLength(transport)
