public static Builder builder() { return builder(true); }
try { Object data; FormParserFactory formParserFactory = FormParserFactory.builder().build(); FormDataParser parser = formParserFactory.createParser(exchange); if (parser != null) { FormData formData = parser.parseBlocking();
public FormParserFactory build() { if(defaultCharset != null) { for (ParserDefinition parser : parsers) { parser.setDefaultEncoding(defaultCharset); } } return new FormParserFactory(parsers); }
/** * Transform the form data into an intermediate request data which can me used * by the web manager * * @param exchange the http server exchange * @return * @throws IOException */ RequestData parseFormData(final HttpServerExchange exchange) throws IOException { // Read post parameters final FormDataParser parser = parserFactory.createParser(exchange); final FormData formData = parser.parseBlocking(); final RequestData data = new RequestData(); for (String name : formData) { final HttpString key = new HttpString(name); data.add(key, formData.get(name)); } return data; }
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { FormDataParser parser = formParserFactory.createParser(exchange); if (parser == null) { next.handleRequest(exchange); return; } if(exchange.isBlocking()) { exchange.putAttachment(FormDataParser.FORM_DATA, parser.parseBlocking()); next.handleRequest(exchange); } else { parser.parse(next); } }
public EagerFormParsingHandler() { this.formParserFactory = FormParserFactory.builder().build(); }
Map<String, Object> formMap = new HashMap<>(); final FormParserFactory parserFactory = FormParserFactory.builder().build(); final FormDataParser parser = parserFactory.createParser(exchange); try { FormData data = parser.parseBlocking();
public AuthenticationMechanismOutcome runFormAuth(final HttpServerExchange exchange, final SecurityContext securityContext) { final FormDataParser parser = formParserFactory.createParser(exchange); if (parser == null) { UndertowLogger.SECURITY_LOGGER.debug("Could not authenticate as no form parser is present");
public FormParserFactory build() { if(defaultCharset != null) { for (ParserDefinition parser : parsers) { parser.setDefaultEncoding(defaultCharset); } } return new FormParserFactory(parsers); }
public FormAuthenticationMechanism(final String name, final String loginPage, final String errorPage) { this(FormParserFactory.builder().build(), name, loginPage, errorPage); }
try { Object data; FormParserFactory formParserFactory = FormParserFactory.builder().build(); FormDataParser parser = formParserFactory.createParser(exchange); if (parser != null) { FormData formData = parser.parseBlocking();
@Override public String getFirstParam(String param) { Deque<String> values = exchange.getQueryParameters().get(param); if (values != null && !values.isEmpty()) { return values.getFirst(); } if (formData == null && "post".equalsIgnoreCase(getMethod())) { FormDataParser parser = formParserFactory.createParser(exchange); try { formData = parser.parseBlocking(); } catch (IOException cause) { throw new RuntimeException("Failed to parse form parameters", cause); } } if (formData != null) { Deque<FormValue> formValues = formData.get(param); if (formValues != null && !formValues.isEmpty()) { FormValue firstValue = formValues.getFirst(); if (!firstValue.isFile()) { return firstValue.getValue(); } } } return null; }
public FormParserFactory build() { if(defaultCharset != null) { for (ParserDefinition parser : parsers) { parser.setDefaultEncoding(defaultCharset); } } return new FormParserFactory(parsers); }
public FormAuthenticationMechanism(final String name, final String loginPage, final String errorPage, final String postLocation) { this(FormParserFactory.builder().build(), name, loginPage, errorPage, postLocation); }
private void getForm(HttpServerExchange exchange) throws IOException { this.form = this.injector.getInstance(Form.class); if (exchange.getRequestMethod().equals(Methods.POST) || exchange.getRequestMethod().equals(Methods.PUT)) { final FormDataParser formDataParser = FormParserFactory.builder().build().createParser(exchange); if (formDataParser != null) { exchange.startBlocking(); FormData formData = formDataParser.parseBlocking(); for (String data : formData) { for (FormData.FormValue formValue : formData.get(data)) { if (formValue.isFile()) { form.addFile(formValue.getFile()); } else { form.add(new HttpString(data).toString(), formValue.getValue()); } } } this.form.setSubmitted(true); } } }
@Override public String getFirstParam(String param) { Deque<String> values = exchange.getQueryParameters().get(param); if (values != null && !values.isEmpty()) { return values.getFirst(); } if (formData == null && "post".equalsIgnoreCase(getMethod())) { FormDataParser parser = formParserFactory.createParser(exchange); try { formData = parser.parseBlocking(); } catch (IOException cause) { throw new RuntimeException("Failed to parse form parameters", cause); } } if (formData != null) { Deque<FormValue> formValues = formData.get(param); if (formValues != null && !formValues.isEmpty()) { FormValue firstValue = formValues.getFirst(); if (!firstValue.isFile()) { return firstValue.getValue(); } } } return null; }
MCMPHandler(MCMPConfig config, ModCluster modCluster, HttpHandler next) { this.config = config; this.next = next; this.modCluster = modCluster; this.container = modCluster.getContainer(); this.parserFactory = FormParserFactory.builder(false).addParser(new FormEncodedDataDefinition().setForceCreation(true)).build(); UndertowLogger.ROOT_LOGGER.mcmpHandlerCreated(); }
@Override public void setCharacterEncoding(final String env) throws UnsupportedEncodingException { if (readStarted) { return; } try { characterEncoding = Charset.forName(env); final ManagedServlet originalServlet = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getOriginalServletPathMatch().getServletChain().getManagedServlet(); final FormDataParser parser = originalServlet.getFormParserFactory().createParser(exchange); if (parser != null) { parser.setCharacterEncoding(env); } } catch (UnsupportedCharsetException e) { throw new UnsupportedEncodingException(); } }
public static Builder builder() { return builder(true); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { final FormDataParser parser = formParserFactory.createParser(exchange); FormData data = parser.parseBlocking(); for (String fieldName : data) {