MCPcopy Create free account
hub / github.com/bugy/script-server / __init__

Method __init__

src/web/streaming_form_reader.py:43–62  ·  view source on GitHub ↗
(self, headers, output_files_path)

Source from the content-addressed store, hash-verified

41class StreamingFormReader:
42
43 def __init__(self, headers, output_files_path) -> None:
44 (content_type, content_type_dict) = parse_header(headers.get('Content-Type'))
45
46 content_length = headers.get('Content-Length')
47 self.max_length = int(content_length) if content_length else 0
48
49 if content_type != 'multipart/form-data':
50 raise Exception('Unsupported content type: ' + content_type)
51
52 if 'boundary' not in content_type_dict:
53 raise Exception('Failed to find boundary in header ' + content_type)
54
55 self._boundary = b'--' + content_type_dict['boundary'].encode('utf-8')
56 self._fields_separator = b'\r\n' + self._boundary
57 self._buffer = b''
58 self._current_part = None
59 self._output_files_path = output_files_path
60 self._read_bytes = 0
61 self.values = {}
62 self.files = {}
63
64 def read(self, chunk):
65 if self._reached_end():

Callers

nothing calls this directly

Calls 2

parse_headerFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected