public static String convert(Fields fields) { return convert(fields, StandardCharsets.UTF_8); }
private ContentProvider formContent(Map params) { Fields fields = new Fields(); params.forEach( (key, value) -> fields.add((String)key, (String)value) ); return new FormContentProvider(fields); }
public static String convert(Fields fields, Charset charset) { // Assume 32 chars between name and value. StringBuilder builder = new StringBuilder(fields.getSize() * 32); for (Fields.Field field : fields) { for (String value : field.getValues()) { if (builder.length() > 0) builder.append("&"); builder.append(encode(field.getName(), charset)).append("=").append(encode(value, charset)); } } return builder.toString(); }
private ContentProvider formContent(Map params) { Fields fields = new Fields(); params.forEach( (key, value) -> fields.add((String)key, (String)value) ); return new FormContentProvider(fields); }
/** * Performs a POST request to the specified URI with the given form parameters. * * @param uri the URI to POST * @param fields the fields composing the form name/value pairs * @return the {@link ContentResponse} for the request * @throws InterruptedException if send threading has been interrupted * @throws ExecutionException the execution failed * @throws TimeoutException the send timed out */ public ContentResponse FORM(URI uri, Fields fields) throws InterruptedException, ExecutionException, TimeoutException { return POST(uri).content(new FormContentProvider(fields)).send(); }
public FormContentProvider(Fields fields, Charset charset) { super("application/x-www-form-urlencoded", convert(fields, charset), charset); }
String content = ""; try { final FormContentProvider entity = new FormContentProvider(fields); final ContentResponse response = AccessController .doPrivileged((PrivilegedExceptionAction<ContentResponse>) () -> {
return new FormContentProvider(formFields((ObjectNode) resolveSecrets(content, secrets)));