本文整理汇总了Java中org.vertx.java.core.MultiMap类的典型用法代码示例。如果您正苦于以下问题:Java MultiMap类的具体用法?Java MultiMap怎么用?Java MultiMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultiMap类属于org.vertx.java.core包,在下文中一共展示了MultiMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
@Override
public void handle(HttpClientResponse clientResponse) {
delegate.handle(clientResponse);
MultiMap headers = clientResponse.headers();
for (String headerName : rewriteHeaders) {
List<String> headerValues = headers.getAll(headerName);
int size = headerValues.size();
if (size > 0) {
List<String> newHeaders = new ArrayList<String>(size);
for (String headerValue : headerValues) {
String newValue = headerValue;
if (headerValue != null && headerValue.length() > 0) {
newValue = proxyMappingDetails.rewriteBackendUrl(headerValue);
}
}
LOG.info("Rewriting header " + headerName + " from: " + headerValues + " to: " + newHeaders);
headers.set(headerName, newHeaders);
}
}
}
示例2: sendFile
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
public static void sendFile(Vertx vertx, String uri, int port, String content,
MultiMap headers, String filename,
String contentType, Handler<HttpClientResponse> handler) {
HttpClientRequest req = vertx.createHttpClient().setPort(port).post(uri, handler);
final String boundary = "dLV9Wyq26L_-JQxk6ferf-RT153LhOO";
Buffer buffer = new Buffer();
final String body = "--" + boundary + "\r\n" +
"Content-Disposition: form-data; name=\"file\"; filename=\""+ filename +"\"\r\n" +
"Content-Type: " + contentType + "\r\n" +
"\r\n" +
content + "\r\n" +
"--" + boundary + "--\r\n";
buffer.appendString(body);
req.headers().add(headers);
req.headers().set("content-length", String.valueOf(buffer.length()));
req.headers().set("content-type", "multipart/form-data; boundary=" + boundary);
req.write(buffer).end();
}
示例3: from
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
public static Query from( final HttpServerRequest request )
{
final MultiMap map = new CaseInsensitiveMultiMap();
final String query = request.query();
if ( query != null )
{
final String[] qe = query.split( "&" );
for ( final String entry : qe )
{
final int idx = entry.indexOf( '=' );
if ( idx > 1 )
{
map.add( entry.substring( 0, idx ), entry.substring( idx + 1 ) );
}
else
{
map.add( entry, "true" );
}
}
}
return new Query( map );
}
示例4: builtInParams_PrefixedPathWithParamsRightAfterPrefix
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
@Test
public void builtInParams_PrefixedPathWithParamsRightAfterPrefix()
throws Exception
{
final String path = "/:type/:name:path=(/.*)";
final String routePath = path;
final String handlerPath = "";
final MultiMap params = getParams( "/api", path, routePath, handlerPath, "/api/remote/foo/" );
final String basePath = "/api";
final String baseUrl = "http://" + host + ":" + port + basePath;
assertThat( params.get( BuiltInParam._classBase.key() ), equalTo( basePath ) );
assertThat( params.get( BuiltInParam._classContextUrl.key() ), equalTo( baseUrl ) );
assertThat( params.get( BuiltInParam._routeBase.key() ), equalTo( basePath ) );
assertThat( params.get( BuiltInParam._routeContextUrl.key() ), equalTo( baseUrl ) );
assertThat( params.get( "type" ), equalTo( "remote" ) );
assertThat( params.get( "name" ), equalTo( "foo" ) );
assertThat( params.get( "path" ), equalTo( "/" ) );
}
示例5: getParam
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
public static String getParam(MultiMap params, String key, String defaultVal) {
if (params.contains(key)) {
List<String> vals = params.getAll(key);
if (vals != null) {
for (String val : vals) {
if (StringUtil.isNotEmpty(val)) {
return val;
}
}
}
}
return defaultVal;
}
示例6: getNow
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
@Override
public HttpClient getNow(String s, MultiMap multiMap, Handler<HttpClientResponse> handler) {
if (httpClient == null) {
handler.handle(new ErrorHttpClientResponse(500, ""));
return this;
}
httpClient.getNow(s, multiMap, handler);
return this;
}
示例7: getParameterEntity
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
private Parameter<String> getParameterEntity(final MultiMap params) {
final List<Parameter<String>> parameters = params.
entries().
stream().
map(entry -> new Parameter<>(entry.getKey(), entry.getValue())).
collect(Collectors.toList());
return new Parameter<>(parameters);
}
示例8: safeMultiMap
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
public static MultiMap safeMultiMap(MultiMap m) {
for (String name : m.names()) {
List<String> values = m.getAll(name);
List<String> safeValues = new ArrayList<>();
if (values == null) continue;
for (String value: values) {
safeValues.add(stripXSS(value));
}
m.set(name, safeValues);
}
return m;
}
示例9: bodyToParams
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
/**
* @deprecated Use request.formAttributes() instead
* @param request http request
* @param handler receive attributes
*/
public void bodyToParams(final HttpServerRequest request, final Handler<MultiMap> handler) {
request.expectMultiPart(true);
request.endHandler(new VoidHandler() {
@Override
protected void handle() {
handler.handle(request.formAttributes());
}
});
}
示例10: jsonFromMultimap
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
public static JsonObject jsonFromMultimap(MultiMap attributes) {
JsonObject json = new JsonObject();
if (attributes != null) {
for (Map.Entry<String, String> e: attributes.entries()) {
json.putString(e.getKey(), e.getValue());
}
}
return json;
}
示例11: getParams
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
private MultiMap getParams( final String prefix, final String bindingPath, final String routePath,
final String handlerPath, final String requestPath )
throws Exception
{
access = new ParamAccess();
server =
vertx.createHttpServer()
.requestHandler( new ApplicationRouter(
new ApplicationRouterConfig().withPrefix( prefix )
.withHandler( access )
.withRouteCollection( new ParamCollection(
bindingPath,
routePath,
handlerPath,
access ) ) ) )
.listen( port, host );
final HttpClientRequest req = client.get( requestPath, clientHandler );
req.end();
synchronized ( clientHandler )
{
clientHandler.wait();
}
return access.params();
}
示例12: setCorsHeaders
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
public void setCorsHeaders(MultiMap headers){
headers.set("Access-Control-Allow-Origin","*");
headers.set("Access-Control-Allow-Credentials", "true");
headers.set("Access-Control-Allow-Methods", "POST, GET");
headers.set("Access-Control-Allow-Headers", "Content-Type, *");
}
示例13: getRequestInfo
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
public static String getRequestInfo(HttpServerRequest request){
StringBuilder reqInfo = new StringBuilder();
String remoteAddress = request.remoteAddress().toString();
MultiMap headers = request.headers();
reqInfo.append(" <br> IP remoteAddress: ").append(remoteAddress);
for (Entry<String, String> header : headers) {
reqInfo.append("<br> ").append(header.getKey()).append(" = ").append(header.getValue());
}
return reqInfo.toString();
}
示例14: headers
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
@Override
public MultiMap headers() {
return headers;
}
示例15: params
import org.vertx.java.core.MultiMap; //导入依赖的package包/类
@Override
public MultiMap params() {
return params;
}