
org.webpieces.httpparser.api.subparsers.UrlEncodedParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-parser1_1 Show documentation
Show all versions of http-parser1_1 Show documentation
A re-usable asynchronous http 1.1 parser that can be used with any nio client
The newest version!
package org.webpieces.httpparser.api.subparsers;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.function.BiFunction;
public class UrlEncodedParser {
public void parse(String multiPartData, BiFunction mapAddFunction) {
try {
String[] pairs = multiPartData.split("\\&");
for (int i = 0; i < pairs.length; i++) {
String[] fields = pairs[i].split("=");
String name = URLDecoder.decode(fields[0], "UTF-8");
String value = null;
if(fields.length == 2)
value = URLDecoder.decode(fields[1], "UTF-8");
mapAddFunction.apply(name, value);
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy