Parse the multipart form data.
438349
private void parseMultipartFormData() {
        String multipartFormDataParser = getSetting(MULTIPART_FORM_DATA_PARSER_SETTING_NAME);
        if (multipartFormDataParser == null) {
            throw new MultipartRequestParseException("The setting name 'multipartFormDataParser' for multipart " +
                    "form data parsing is not specified. Please specify 'multipartFormDataParser' via Aspect so " +
                    "that Translet can parse multipart form data.");
        }

        MultipartFormDataParser parser = getBean(multipartFormDataParser);
        if (parser == null) {
            throw new MultipartRequestParseException("No bean named '" + multipartFormDataParser + "' is defined");
        }
        parser.parse(getRequestAdapter());
    }
1303042
def process_formdata(self, valuelist):
        """"""
        if valuelist:
            self.data = '\n'.join([
                x.strip() for x in
                filter(lambda x: x, '\n'.join(valuelist).splitlines())
            ])
1121713
private void parseBodyMultipart() {
        if (undecodedChunk == null || undecodedChunk.readableBytes() == 0) {
            // nothing to decode
            return;
        }
        InterfaceHttpData data = decodeMultipart(currentStatus);
        while (data != null) {
            addHttpData(data);
            if (currentStatus == MultiPartStatus.PREEPILOGUE || currentStatus == MultiPartStatus.EPILOGUE) {
                break;
            }
            data = decodeMultipart(currentStatus);
        }
    }
1272995
private function parsePut()
    {
        $contentType = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : 'application/x-www-form-urlencoded';

        $tmp = explode(';', $contentType);
        $boundary = '';
        $encoding = '';

        $contentType = array_shift($tmp);

        foreach ($tmp as $t) {
            if (strpos($t, 'boundary') !== false) {
                $t = explode('=', $t, 2);
                if (isset($t[1])) {
                    $boundary = '--' . $t[1];
                }
            } elseif (strpos($t, 'charset') !== false) {
                $t = explode('=', $t, 2);
                if (isset($t[1])) {
                    $encoding = $t[1];
                }
            }
            if ($boundary !== '' && $encoding !== '') {
                break;
            }
        }

        switch ($contentType) {
            case 'multipart/form-data':
                #grab multipart boundary from content type header
                if (!empty($boundary)) {
                    break;
                }
                $contentType = 'application/x-www-form-urlencoded';
            // Fallthrough intentional - no boundary supplied with multipart content-type, so treat as url encoded
            case 'application/x-www-form-urlencoded':
                parse_str(file_get_contents($this->unitTestRequestFile ?: 'php://input'), $_POST);
                return;
            default:
                return;
        }

        $_FILES = [];
        $_POST = [];
        $chunkLength = 8096;
        $raw_headers = '';

        $stream = fopen($this->unitTestRequestFile ?: 'php://input', 'rb');

        $sanity = fgets($stream, strlen($boundary) + 5);

        // Skip initial blank line
        if ($sanity == "\r\n") {
            $sanity = fgets($stream, strlen($boundary) + 5);
        }

        if (rtrim($sanity) !== $boundary) {
            #malformed file, boundary should be first item
            return;
        }

        while (($chunk = fgets($stream)) !== false) {
            if ($chunk === $boundary) {
                continue;
            }

            if (rtrim($chunk) == '') { #blank line means we have all the headers and are going to read content
                $raw_headers = explode("\r\n", $raw_headers);
                $headers = [];
                $matches = [];

                foreach ($raw_headers as $header) {
                    if (strpos($header, ':') === false) {
                        continue;
                    }
                    list($name, $value) = explode(':', $header, 2);
                    $headers[strtolower($name)] = ltrim($value, ' ');
                }

                $raw_headers = '';

                if (!isset($headers['content-disposition'])) {
                    continue;
                }

                $filename = null;
                preg_match(
                    '/^(.+); *name="([^"]+)"(; *filename="([^"]+)")?/',
                    $headers['content-disposition'],
                    $matches
                );
                list(, $type, $name) = $matches;

                #process data
                if (isset($matches[4])) { #pull in file
                    $error = UPLOAD_ERR_OK;

                    $filename = $matches[4];
                    $filename_parts = pathinfo($filename);
                    $contentType = 'unknown';

                    if (isset($headers['content-type'])) {
                        $tmp = explode(';', $headers['content-type']);
                        $contentType = $tmp[0];
                    }

                    $tmpnam = tempnam(ini_get('upload_tmp_dir'), 'php');
                    $fileHandle = fopen($tmpnam, 'wb');


                    if ($fileHandle === false) {
                        $error = UPLOAD_ERR_CANT_WRITE;
                    } else {
                        $lastLine = null;
                        while (($chunk = fgets($stream, $chunkLength)) !== false && strpos($chunk, $boundary) !== 0) {
                            if ($lastLine !== null) {
                                if (fwrite($fileHandle, $lastLine) === false) {
                                    $error = UPLOAD_ERR_CANT_WRITE;
                                    break;
                                }
                            }
                            $lastLine = $chunk;
                        }

                        if ($lastLine !== null && $error !== UPLOAD_ERR_CANT_WRITE) {
                            if (fwrite($fileHandle, rtrim($lastLine, "\r\n")) === false) {
                                $error = UPLOAD_ERR_CANT_WRITE;
                            }
                        }
                    }

                    $_FILES[$name] = [
                        'name' => $filename,
                        'type' => $contentType,
                        'tmp_name' => $tmpnam,
                        'error' => $error,
                        'size' => filesize($tmpnam)
                    ];

                    continue;
                } else { #pull in variable
                    $fullValue = '';
                    $lastLine = null;
                    while (($chunk = fgets($stream)) !== false && strpos($chunk, $boundary) !== 0) {
                        if ($lastLine !== null) {
                            $fullValue .= $lastLine;
                        }

                        $lastLine = $chunk;
                    }

                    if ($lastLine !== null) {
                        $fullValue .= rtrim($lastLine, "\r\n");
                    }

                    if (isset($headers['content-type'])) {
                        $tmp = explode(';', $headers['content-type']);
                        $encoding = '';

                        foreach ($tmp as $t) {
                            if (strpos($t, 'charset') !== false) {
                                $t = explode($t, '=', 2);
                                if (isset($t[1])) {
                                    $encoding = $t[1];
                                }
                                break;
                            }
                        }

                        if ($encoding !== '' && strtoupper($encoding) !== 'UTF-8' && strtoupper($encoding) !== 'UTF8') {
                            $tmp = mb_convert_encoding($fullValue, 'UTF-8', $encoding);
                            if ($tmp !== false) {
                                $fullValue = $tmp;
                            }
                        }

                    }

                    $fullValue = $name . '=' . $fullValue;
                    $origName = $name;
                    $tmp = [];
                    parse_str($fullValue, $tmp);
                    $_POST = $this->recursiveSetter($origName, $_POST, $tmp);
                }
                continue;
            }

            $raw_headers .= $chunk;
        }

        $GLOBALS['_PUT'] = $_POST;
        fclose($stream);
    }
71281
def encode_multipart_formdata(self, fields, files, baseName, verbose=False):
        
        BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
        CRLF = '\r\n'
        content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
        if verbose is True:
            print(('Encoding ' + baseName + ' for upload...'))
        fin = self._open(files, 'rb')
        fout = self._open(files + '.b64', 'wb')
        fout.write(bytearray('--' + BOUNDARY + CRLF, 'utf-8'))
        fout.write(bytearray('Content-Disposition: form-data'
                             '; name="file"; filename="' + baseName + '"' + CRLF, "utf-8"))
        fout.write(bytearray('Content-Type: application/octet-stream' + CRLF,
                             'utf-8'))
        fout.write(bytearray(CRLF, 'utf-8'))
        shutil.copyfileobj(fin, fout)
        fout.write(bytearray(CRLF, 'utf-8'))
        fout.write(bytearray('--' + BOUNDARY + '--' + CRLF, 'utf-8'))
        fout.write(bytearray(CRLF, 'utf-8'))
        fout.close()
        fin.close()
        return content_type
1167777
function parse(data){
			var out = {};
     		if(data.entry){

	    		var entry = data.entry[0];
	    		
	    		// map data into ufData format from api json

	        	if(utils.getNodeVaue('name.givenName', entry) !== ''){
	        		out['given-name'] = utils.getNodeVaue('name.givenName', entry)
	        	}	

	        	if(utils.getNodeVaue('name.familyName', entry) !== ''){
	        		out['family-name'] = utils.getNodeVaue('name.familyName', entry)
	        	}	

	        	if(utils.getNodeVaue('name.formatted', entry) !== ''){
	        		out.name = utils.getNodeVaue('name.formatted', entry)
	        	}	

	        	if(entry.thumbnailUrl){
	        		out.photo = [entry.thumbnailUrl]
	        	}

	        	if(entry.aboutMe){
	        		out.note = [entry.aboutMe]
	        	}

	        	if(entry.urls){
	        		if(!out.url) {out.url = []};
	        		var i = entry.urls.length;
					var x = 0;
					while (x < i) {
					    out.url.push(entry.urls[x].value);
					    x++;
					}
				}

				if(entry.phoneNumbers){
	        		if(!out.tel) {out.tel = []};
	        		var i = entry.phoneNumbers.length;
					var x = 0;
					while (x < i) {
						if(entry.phoneNumbers[x].type === 'mobile'){
							entry.phoneNumbers[x].type = 'cell'
						}
					    out.tel.push(entry.phoneNumbers[x]);
					    x++;
					}
				}

				if(entry.emails){
	        		if(!out.email) {out.email = []};
	        		var i = entry.emails.length;
					var x = 0;
					while (x < i) {
						if(entry.emails[x].primary && entry.emails[x].primary == 'true'){
							entry.emails[x].type = 'pref';
							delete entry.emails[x].primary;
						}
					    out.email.push(entry.emails[x]);
					    x++;
					}
				}
			}
			return {type: ['h-card'], properties: out};
		}
919921
def parse_multipart_form(body, boundary):
    
    files = RequestParameters()
    fields = RequestParameters()

    form_parts = body.split(boundary)
    for form_part in form_parts[1:-1]:
        file_name = None
        content_type = "text/plain"
        content_charset = "utf-8"
        field_name = None
        line_index = 2
        line_end_index = 0
        while not line_end_index == -1:
            line_end_index = form_part.find(b"\r\n", line_index)
            form_line = form_part[line_index:line_end_index].decode("utf-8")
            line_index = line_end_index + 2

            if not form_line:
                break

            colon_index = form_line.index(":")
            form_header_field = form_line[0:colon_index].lower()
            form_header_value, form_parameters = parse_header(
                form_line[colon_index + 2 :]
            )

            if form_header_field == "content-disposition":
                field_name = form_parameters.get("name")
                file_name = form_parameters.get("filename")

                # non-ASCII filenames in RFC2231, "filename*" format
                if file_name is None and form_parameters.get("filename*"):
                    encoding, _, value = email.utils.decode_rfc2231(
                        form_parameters["filename*"]
                    )
                    file_name = unquote(value, encoding=encoding)
            elif form_header_field == "content-type":
                content_type = form_header_value
                content_charset = form_parameters.get("charset", "utf-8")

        if field_name:
            post_data = form_part[line_index:-4]
            if file_name is None:
                value = post_data.decode(content_charset)
                if field_name in fields:
                    fields[field_name].append(value)
                else:
                    fields[field_name] = [value]
            else:
                form_file = File(
                    type=content_type, name=file_name, body=post_data
                )
                if field_name in files:
                    files[field_name].append(form_file)
                else:
                    files[field_name] = [form_file]
        else:
            logger.debug(
                "Form-data field does not have a 'name' parameter "
                "in the Content-Disposition header"
            )

    return fields, files
1263516
def make_form_data_parser(self):
        
        return self.form_data_parser_class(self._get_file_stream,
                                           self.charset,
                                           self.encoding_errors,
                                           self.max_form_memory_size,
                                           self.max_content_length,
                                           self.parameter_storage_class)
1216062
async def parse(self, request):
        
        if request.content_type in {'application/x-www-form-urlencoded', 'multipart/form-data'}:
            return await request.post()

        if request.content_type == 'application/json':
            return await request.json()

        return await request.text()
526129
private static function getParsedInput()
    {
        $input = file_get_contents('php://input') ?: null;

        switch (self::getContentType()) {
            case 'application/atom+xml':
                $input = new \SimpleXmlElement($input);
                break;
            case 'text/html':
            case 'text/plain':
            case 'application/json':
            case 'application/javascript':
                $input = json_decode($input, true);
                break;
            case 'multipart/form-data':
            case 'application/x-www-form-urlencoded':
                $data = [];
                self::parseRaw($input, $data);
                $input = $data;
                break;
        }

        return $input ?? [];
    }
931912
def user_parse(data):
        """"""
        resp = data.get('response', [{}])[0]
        yield 'id', resp.get('uid')
        yield 'first_name', resp.get('first_name')
        yield 'last_name', resp.get('last_name')
        yield 'username', resp.get('nickname')
        yield 'city', resp.get('city')
        yield 'country', resp.get('country')
        yield 'picture', resp.get('photo_big')
340889
protected function parseBody()
    {
        $data = null;
        
        switch ($this->getContentType()) {
            case 'application/x-www-form-urlencoded':
                $data = $this->parseUrlEncodedBody();
                break;
            case 'application/json':
                $data = $this->parseJsonBody();
                break;
            case 'text/xml':
            case 'application/xml':
                $data = $this->parseXmlBody();
                break;
            case 'multipart/form-data':
                throw new \RuntimeException("Parsing multipart/form-data isn't supported");
        }
        
        return $data;
    }
1212970
def parse(self, response):
        """"""
        info = response.get('info')
        res = self._regex.search(info)

        self._processed += int(res.group(1))
        self._failed += int(res.group(2))
        self._total += int(res.group(3))
        self._time += Decimal(res.group(4))
        self._chunk += 1
513649
def _parse_byte_data(self, byte_data):
        """"""
        self.length, self.data_type = unpack('<ii', byte_data[:self.size])
411222
function parseForm(form) {
    var result = {};
    if (typeof form === 'undefined' || form===null)
        return result;
    var keys = Object.keys(form);
    keys.forEach(function(key) {
        if (form.hasOwnProperty(key))
        {
            extend(result, key, form[key]);
        }
    });
    return result;
}
148703
async def form(self, *,
                   encoding: Optional[str]=None) -> List[Tuple[str, str]]:
        
        data = await self.read(decode=True)
        if not data:
            return []
        if encoding is not None:
            real_encoding = encoding
        else:
            real_encoding = self.get_charset(default='utf-8')
        return parse_qsl(data.rstrip().decode(real_encoding),
                         keep_blank_values=True,
                         encoding=real_encoding)
487258
function parseBody()
    {
        $result = array(
            'data'=>array(),
            'files'=>array(),
            );

         // read incoming data
        $input = Instance::get('BODY');

        // grab multipart boundary from content type header
        preg_match('/boundary=(.*)$/', $_SERVER['CONTENT_TYPE'], $matches);

        // content type is probably regular form-encoded
        if (!count($matches)) {
            // we expect regular puts to containt a query string containing data
            parse_str($input, $result['data']);
        } else {
            $boundary = $matches[1];
            // split content by boundary and get rid of last -- element
            $a_blocks = preg_split("/-+$boundary/", $input);
            array_pop($a_blocks);

            // loop data blocks
            foreach ($a_blocks as $id => $block) {
                if (empty($block))
                    continue;
                // you'll have to var_dump $block to understand this and maybe replace \n or \r with a visibile char
                // parse uploaded files
                if (strpos($block, 'application/octet-stream') !== FALSE) {
                    // match "name", then everything after "stream" (optional) except for prepending newlines
                    // preg_match("/name=\"([^\"]*)\".*stream[\n|\r]+([^\n\r].*)?$/s", $block, $matches);
                    // $a_data['files'][$matches[1]] = isset($matches[2])?$matches[2]:null;
                }
                // parse all other fields
                else {
                    // match "name" and optional value in between newline sequences
                    if (strpos($block, 'filename="')===false) {
                        preg_match('/name=\"([^\"]*)\"[\n|\r]+([^\n\r].*)?\r$/s', $block, $matches);
                        $result['data'][$matches[1]] = isset($matches[2])?$matches[2]:null;
                    } else {
                        preg_match('/; name=\"([^\"]*)\"; filename=\"([^\"]*)\"\s*Content\-Type: ([\w\/]+)[\n|\r]+([^\n\r].*)?\r$/s', $block, $matches);
                        $result['files'][$matches[1]] = array(
                            'name' => $matches[2],
                            'type' => $matches[3],
                            'tmp_name' => tempnam( ini_get( 'upload_tmp_dir' ), 'php' ),
                            'error' => UPLOAD_ERR_OK,
                            'size' => 0);
                        $result['files'][$matches[1]]['size'] = file_put_contents($result['files'][$matches[1]]['tmp_name'], $matches[4]);
                        $result['files'][$matches[1]]['size']!==false || $result['files'][$matches[1]]['error'] = UPLOAD_ERR_CANT_WRITE;
                    }
                }
            }
        }

        return $result;
    }