MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / _write_mime_data

Method _write_mime_data

thirdparty/clientform/clientform.py:1452–1485  ·  view source on GitHub ↗
(self, mw, _name, _value)

Source from the content-addressed store, hash-verified

1450 return [(self._index, self.name, "")]
1451
1452 def _write_mime_data(self, mw, _name, _value):
1453 # called by HTMLForm
1454 # assert _name == self.name and _value == ''
1455 if len(self._upload_data) < 2:
1456 if len(self._upload_data) == 0:
1457 file_object = _cStringIO()
1458 content_type = "application/octet-stream"
1459 filename = ""
1460 else:
1461 file_object, content_type, filename = self._upload_data[0]
1462 if filename is None:
1463 filename = ""
1464 mw2 = mw.nextpart()
1465 fn_part = '; filename="%s"' % filename
1466 disp = 'form-data; name="%s"%s' % (self.name, fn_part)
1467 mw2.addheader("Content-Disposition", disp, prefix=1)
1468 fh = mw2.startbody(content_type, prefix=0)
1469 fh.write(file_object.read())
1470 else:
1471 # multiple files
1472 mw2 = mw.nextpart()
1473 disp = 'form-data; name="%s"' % self.name
1474 mw2.addheader("Content-Disposition", disp, prefix=1)
1475 fh = mw2.startmultipartbody("mixed", prefix=0)
1476 for file_object, content_type, filename in self._upload_data:
1477 mw3 = mw2.nextpart()
1478 if filename is None:
1479 filename = ""
1480 fn_part = '; filename="%s"' % filename
1481 disp = "file%s" % fn_part
1482 mw3.addheader("Content-Disposition", disp, prefix=1)
1483 fh2 = mw3.startbody(content_type, prefix=0)
1484 fh2.write(file_object.read())
1485 mw2.lastpart()
1486
1487 def __str__(self):
1488 name = self.name

Callers

nothing calls this directly

Calls 7

nextpartMethod · 0.80
addheaderMethod · 0.80
startbodyMethod · 0.80
startmultipartbodyMethod · 0.80
lastpartMethod · 0.80
writeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected