Java Code Examples for io.undertow.server.handlers.form.FormParserFactory#builder()
The following examples show how to use
io.undertow.server.handlers.form.FormParserFactory#builder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HTTPIOHandler.java From core-ng-project with Apache License 2.0 | 5 votes |
HTTPIOHandler(HTTPHandler handler, ShutdownHandler shutdownHandler) { this.handler = handler; this.shutdownHandler = shutdownHandler; var builder = FormParserFactory.builder(); builder.setDefaultCharset(UTF_8.name()); formParserFactory = builder.build(); }
Example 2
Source File: FormHandler.java From mangooio with Apache License 2.0 | 5 votes |
/** * Retrieves the form parameter from a request * * @param exchange The Undertow HttpServerExchange * * @throws IOException */ @SuppressWarnings("rawtypes") protected Form getForm(HttpServerExchange exchange) throws IOException { final Form form = Application.getInstance(Form.class); if (RequestUtils.isPostPutPatch(exchange)) { final Builder builder = FormParserFactory.builder(); builder.setDefaultCharset(StandardCharsets.UTF_8.name()); try (final FormDataParser formDataParser = builder.build().createParser(exchange)) { if (formDataParser != null) { exchange.startBlocking(); final FormData formData = formDataParser.parseBlocking(); for (String data : formData) { Deque<FormValue> deque = formData.get(data); if (deque != null) { FormValue formValue = deque.element(); if (formValue != null) { if (formValue.isFileItem() && formValue.getFileItem().getFile() != null) { form.addFile(Files.newInputStream(formValue.getFileItem().getFile())); } else { if (data.contains("[]")) { String key = StringUtils.replace(data, "[]", ""); for (Iterator iterator = deque.iterator(); iterator.hasNext();) { form.addValueList(new HttpString(key).toString(), ((FormValue) iterator.next()).getValue()); } } else { form.addValue(new HttpString(data).toString(), formValue.getValue()); } } } } } } } form.setSubmitted(true); } return form; }