本文整理匯總了Java中io.vertx.core.MultiMap類的典型用法代碼示例。如果您正苦於以下問題:Java MultiMap類的具體用法?Java MultiMap怎麽用?Java MultiMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MultiMap類屬於io.vertx.core包,在下文中一共展示了MultiMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: call
import io.vertx.core.MultiMap; //導入依賴的package包/類
public static JsonObject call(HttpServerRequest httpServerRequest) {
JsonObject jsonObject = new JsonObject();
String query = httpServerRequest.query();
String requestLine = String.format("%s %s%s %s", httpServerRequest.method(), httpServerRequest.path(), query != null ? '?' + query : "", httpServerRequest.version().toString());
jsonObject.put("request_line", requestLine);
MultiMap headers = httpServerRequest.headers();
JsonArray jsonHeaders = new JsonArray();
for (String headerName : headers.names()) {
List<String> values = headers.getAll(headerName);
JsonObject jsonHeader = new JsonObject();
jsonHeader.put(headerName, values);
jsonHeaders.add(jsonHeader);
}
jsonObject.put("headers", jsonHeaders);
return jsonObject;
}
示例2: getFormattedElement
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Override
public String getFormattedElement(AccessLogParam accessLogParam) {
HttpServerResponse response = accessLogParam.getRoutingContext().response();
if (null == response) {
return RESULT_NOT_FOUND;
}
MultiMap headers = response.headers();
if (null == headers) {
return RESULT_NOT_FOUND;
}
String result = headers.get(identifier);
if (null == result) {
return RESULT_NOT_FOUND;
}
return result;
}
示例3: TileCtx
import io.vertx.core.MultiMap; //導入依賴的package包/類
/**
* Default constructor.
* @param params {@link io.vertx.core.http.HttpServerRequest} parameters
* required for rendering an image region.
* @param omeroSessionKey OMERO session key.
*/
TileCtx(MultiMap params, String omeroSessionKey) {
this.omeroSessionKey = omeroSessionKey;
imageId = Long.parseLong(params.get("imageId"));
z = Integer.parseInt(params.get("z"));
c = Integer.parseInt(params.get("c"));
t = Integer.parseInt(params.get("t"));
Integer x = Optional.ofNullable(params.get("x"))
.map(Integer::parseInt)
.orElse(0);
Integer y = Optional.ofNullable(params.get("y"))
.map(Integer::parseInt)
.orElse(0);
Integer width = Optional.ofNullable(params.get("w"))
.map(Integer::parseInt)
.orElse(0);
Integer height = Optional.ofNullable(params.get("h"))
.map(Integer::parseInt)
.orElse(0);
region = new RegionDef(x, y, width, height);
resolution = Optional.ofNullable(params.get("resolution"))
.map(Integer::parseInt)
.orElse(null);
format = params.get("format");
}
示例4: set
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Override
public MultiMap set(final String name, final Iterable<String> values) {
Objects.requireNonNull(values, "values");
int h = hash(name);
int i = index(h);
remove0(h, i, name);
for (String v : values) {
if (v == null) {
break;
}
add0(h, i, name, v);
}
return this;
}
示例5: in
import io.vertx.core.MultiMap; //導入依賴的package包/類
public static void in(final IpcData data, final Envelop envelop) {
if (null != envelop) {
// User
final User user = envelop.user();
final JsonObject sendData = new JsonObject();
if (null != user) {
sendData.put("user", user.principal());
}
// Header
final MultiMap headers = envelop.headers();
if (null != headers) {
final JsonObject headerData = new JsonObject();
headers.forEach((entry) -> headerData.put(entry.getKey(), entry.getValue()));
sendData.put("header", headerData);
}
// Data
final Object content = envelop.data();
sendData.put("data", content);
sendData.put("config", data.getConfig());
// Data Prepared finished.
sendData.put("address", data.getAddress());
data.setData(sendData.toBuffer());
}
}
示例6: call
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Override
public SfsRequest call(SfsRequest httpServerRequest) {
MultiMap headers = httpServerRequest.headers();
String value = headers.get(headerName);
if (value != null) {
boolean failed = false;
BaseEncoding baseEncoding = base64();
try {
byte[] decoded = baseEncoding.decode(value);
if (decoded == null || !value.equals(baseEncoding.encode(decoded))) {
failed = true;
}
} catch (Throwable e) {
// do nothing
}
if (failed) {
JsonObject jsonObject = new JsonObject()
.put("message", format("%s must be Base64 encoded", headerName));
throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
}
}
return httpServerRequest;
}
示例7: testArrayMulti
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Test()
public void testArrayMulti() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("array");
parameter.setCollectionFormat("multi");
List<String> paramsList = new ArrayList<>();
paramsList.add("toto");
paramsList.add("tutu");
paramsList.add("titi");
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, paramsList);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertArrayEquals(paramsList.toArray(), ((List) result).toArray());
}
示例8: call
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Override
public SfsRequest call(SfsRequest httpServerRequest) {
MultiMap headers = httpServerRequest.headers();
String value = headers.get(headerName);
if (value != null) {
Long parsed = tryParse(value);
if (parsed == null || parsed < min || parsed > max) {
JsonObject jsonObject = new JsonObject()
.put("message", format("%s must be between %d and %d", headerName, min, max));
throw new HttpRequestValidationException(HTTP_BAD_REQUEST, jsonObject);
}
}
return httpServerRequest;
}
示例9: call
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Override
public HttpClientResponse call(HttpClientResponse httpClientResponse) {
if (LOGGER.isDebugEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("\r\nHttp Header Dump >>>>>\r\n\r\n");
sb.append(format("HTTP/1.1 %d %s\r\n", httpClientResponse.statusCode(), httpClientResponse.statusMessage()));
MultiMap headers = httpClientResponse.headers();
for (String headerName : headers.names()) {
List<String> values = headers.getAll(headerName);
sb.append(format("%s: %s\r\n", headerName, on(',').join(values)));
}
sb.append("\r\n");
sb.append("Http Header Dump <<<<<\r\n");
LOGGER.debug(sb.toString());
}
return httpClientResponse;
}
示例10: getQueryParameters
import io.vertx.core.MultiMap; //導入依賴的package包/類
/**
* Return the query parameters which do not include the the first & or ? character.
*
* @return Query string
*/
default String getQueryParameters() {
StringBuilder query = new StringBuilder();
MultiMap params = getParameters();
for (Entry<String, String> entry : params.entries()) {
String value = entry.getValue();
if (value != null) {
if (query.length() != 0) {
query.append("&");
}
// try {
query.append(entry.getKey() + "=" + value);// URLEncoder.encode(value, "UTF-8"));
// } catch (UnsupportedEncodingException e) {
// }
}
}
return query.toString();
}
示例11: call
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Override
public T call(T httpServerRequest) {
if (LOGGER.isDebugEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("\r\nHttp Header Dump >>>>>\r\n\r\n");
String query = httpServerRequest.query();
sb.append(format("%s %s%s %s\r\n", httpServerRequest.method(), httpServerRequest.path(), query != null ? '?' + query : "", httpServerRequest.version().toString()));
MultiMap headers = httpServerRequest.headers();
for (String headerName : headers.names()) {
List<String> values = headers.getAll(headerName);
sb.append(format("%s: %s\r\n", headerName, on(',').join(values)));
}
sb.append("\r\n");
sb.append("Http Header Dump <<<<<\r\n");
LOGGER.debug(sb.toString());
}
return httpServerRequest;
}
示例12: testRequestBegin
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Test
public void testRequestBegin() {
SocketAddress socketMetric = mock(SocketAddress.class);
SocketAddress localAddress = mock(SocketAddress.class);
SocketAddress remoteAddress = mock(SocketAddress.class);
HttpClientRequest request = mock(HttpClientRequest.class);
MultiMap headers = mock(MultiMap.class);
when(headers.get(eq(Tags.TRACK_HEADER.toString()))).thenReturn("tag");
when(request.headers()).thenReturn(headers);
HttpRequestMetrics metrics = victim.requestBegin(null, socketMetric, localAddress, remoteAddress, request);
assertNotNull(metrics);
assertEquals(remoteAddress, metrics.getAddress());
}
示例13: call
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Override
public HttpClientResponse call(HttpClientResponse httpClientResponse) {
out.println("Assert #" + assertIndex);
MultiMap headers = httpClientResponse.headers();
String etag = headers.get(ETAG);
String contentMd5 = headers.get(CONTENT_MD5);
String contentSha512 = headers.get(X_CONTENT_SHA512);
String versionId = headers.get(X_CONTENT_VERSION);
String contentLength = headers.get(CONTENT_LENGTH);
String acceptRanges = headers.get(ACCEPT_RANGES);
String lastModified = headers.get(LAST_MODIFIED);
String date = headers.get(DATE);
String serverSideEncryption = headers.get(X_SERVER_SIDE_ENCRYPTION);
assertEquals(context, base16().lowerCase().encode(dataMd5), etag);
assertEquals(context, base64().encode(dataMd5), contentMd5);
assertEquals(context, base64().encode(dataSha512), contentSha512);
assertEquals(context, expectedVersion, parseLong(versionId));
//VertxAssert.assertEquals(context, expectedContentLength, Long.parseLong(contentLength));
assertEquals(context, "none", acceptRanges);
assertNotNull(context, lastModified);
assertNotNull(context, date);
assertEquals(context, this.serverSideEncryption, parseBoolean(serverSideEncryption));
return httpClientResponse;
}
示例14: execute
import io.vertx.core.MultiMap; //導入依賴的package包/類
public Observable<Void> execute(VertxContext<Server> vertxContext, String jobId, MultiMap parameters) {
return Defer.aVoid()
.doOnNext(aVoid -> checkMaster(vertxContext))
.map(aVoid -> getJob(jobId))
.map(this::newInstance)
.flatMap(job ->
Observable.using(
() -> runningJobs.putIfAbsent(jobId, job) == null,
running -> {
if (running) {
return job.execute(vertxContext, parameters);
} else {
return Observable.error(new JobAlreadyRunning());
}
},
running -> {
if (running) {
runningJobs.remove(jobId);
}
}));
}
示例15: push
import io.vertx.core.MultiMap; //導入依賴的package包/類
@Override
public HttpServerResponse push(HttpMethod method, String host, String path, MultiMap headers, Handler<AsyncResult<HttpServerResponse>> handler) {
ObservableFuture<Void> h = RxHelper.observableFuture();
stopKeepAlive(h);
h.subscribe(new Subscriber<Void>() {
@Override
public void onCompleted() {
delegate.push(method, host, path, headers, handler);
}
@Override
public void onError(Throwable e) {
handleThrowable(e);
}
@Override
public void onNext(Void aVoid) {
}
});
return this;
}