Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _writeFile(self, name, filename, content_type, producer, consumer):
cdisp = _Header("Content-Disposition", "form-data")
cdisp.add_param("name", name)
if filename:
cdisp.add_param("filename", filename)
consumer.write(str(cdisp) + CRLF)
consumer.write(str(_Header("Content-Type", content_type)) + CRLF)
if producer.length != UNKNOWN_LENGTH:
consumer.write(
str(_Header("Content-Length", producer.length)) + CRLF)
consumer.write(CRLF)
if isinstance(consumer, _LengthConsumer):
consumer.write(producer.length)
else:
self._currentProducer = producer
def unset(val):
self._currentProducer = None
return val
d = producer.startProducing(consumer)
d.addCallback(unset)
return d
def _writeFile(self, name, filename, content_type, producer, consumer):
cdisp = _Header("Content-Disposition", "form-data")
cdisp.add_param("name", name)
if filename:
cdisp.add_param("filename", filename)
consumer.write(str(cdisp) + CRLF)
consumer.write(str(_Header("Content-Type", content_type)) + CRLF)
if producer.length != UNKNOWN_LENGTH:
consumer.write(
str(_Header("Content-Length", producer.length)) + CRLF)
consumer.write(CRLF)
if isinstance(consumer, _LengthConsumer):
consumer.write(producer.length)
else:
self._currentProducer = producer
def unset(val):
self._currentProducer = None
return val
d = producer.startProducing(consumer)
d.addCallback(unset)
def _writeFile(self, name, filename, content_type, producer, consumer):
cdisp = _Header("Content-Disposition", "form-data")
cdisp.add_param("name", name)
if filename:
cdisp.add_param("filename", filename)
consumer.write(str(cdisp) + CRLF)
consumer.write(str(_Header("Content-Type", content_type)) + CRLF)
if producer.length != UNKNOWN_LENGTH:
consumer.write(
str(_Header("Content-Length", producer.length)) + CRLF)
consumer.write(CRLF)
if isinstance(consumer, _LengthConsumer):
consumer.write(producer.length)
else:
self._currentProducer = producer
def _writeString(self, name, value, consumer):
cdisp = _Header("Content-Disposition", "form-data")
cdisp.add_param("name", name)
consumer.write(str(cdisp) + CRLF + CRLF)
encoded = value.encode("utf-8")
consumer.write(encoded)
self._currentProducer = None