本文整理了Java中io.vertx.reactivex.core.MultiMap
类的一些代码示例,展示了MultiMap
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultiMap
类的具体详情如下:
包路径:io.vertx.reactivex.core.MultiMap
类名称:MultiMap
暂无
代码示例来源:origin: io.knotx/knotx-core
private void writeHeaders(final HttpServerResponse response,
final ClientResponse clientResponse) {
clientResponse.getHeaders().names().stream()
.filter(this::headerFilter)
.forEach(
name ->
clientResponse.getHeaders()
.getAll(name)
.forEach(value -> response.headers().add(name, value))
);
response.headers().remove(HttpHeaders.CONTENT_LENGTH.toString());
}
代码示例来源:origin: io.gravitee.am.gateway.handlers/gravitee-am-gateway-handler
private User convert(MultiMap params) {
User user = new User();
user.setUsername(params.get("username"));
user.setFirstName(params.get("firstName"));
user.setLastName(params.get("lastName"));
user.setEmail(params.get("email"));
user.setPassword(params.get("password"));
return user;
}
}
代码示例来源:origin: io.knotx/knotx-core
private MultiMap headers(Optional<String> contentType) {
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
contentType.ifPresent(s -> headers.add("Content-Type", s));
return headers;
}
代码示例来源:origin: io.knotx/knotx-core
public ClientRequest(ClientRequest request) {
this.path = request.path;
this.method = request.method;
this.headers = MultiMap.caseInsensitiveMultiMap().setAll(request.headers);
this.params = MultiMap.caseInsensitiveMultiMap().setAll(request.params);
this.formAttributes = MultiMap.caseInsensitiveMultiMap().setAll(request.formAttributes);
}
代码示例来源:origin: Cognifide/knotx
/**
* Equality operator for MultiMap objects.
* MultiMap represents keys as String, values as List of Strings.
*
* @param self - compared {@link MultiMap} object self
* @param that - compared {@link MultiMap} object that
* @return - true if objects are equals, false otherwise
*/
public static boolean equalsMultiMap(MultiMap self, MultiMap that) {
return Objects.equal(self.names(), that.names()) &&
self.names().stream()
.allMatch(name -> that.contains(name) && self.getAll(name).equals(that.getAll(name)));
}
代码示例来源:origin: io.knotx.acme/acme-forms-adapter-http
private void updateRequestHeaders(HttpRequest<Buffer> request, ClientRequest serviceRequest,
HttpFormsSettings serviceMetadata) {
MultiMap filteredHeaders = getFilteredHeaders(serviceRequest.getHeaders(),
serviceMetadata.getAllowedRequestHeadersPatterns());
filteredHeaders.names().forEach(
headerName -> filteredHeaders.getAll(headerName)
.forEach(value -> request.headers().add(headerName, value)));
if (customHttpHeader != null) {
request.headers().set(
customHttpHeader.getName(),
customHttpHeader.getValue()
);
}
}
代码示例来源:origin: io.knotx/knotx-core
private void writeHeaders(HttpServerResponse response, MultiMap headers) {
headers.names().stream()
.filter(this::headerFilter)
.forEach(
name ->
headers
.getAll(name)
.forEach(value -> response.putHeader(name, value))
);
}
代码示例来源:origin: io.knotx/knotx-core
@Override
public BiConsumer<MultiMap, T> accumulator() {
return (multiMap, t) -> value.apply(t)
.forEach(v -> multiMap.add(keyGetter.apply(t), v));
}
代码示例来源:origin: Cognifide/knotx
private KnotContext redirectKnotResponse(KnotContext knotContext, FormEntity form,
ClientResponse clientResponse, String redirectLocation) {
LOGGER.debug("Request redirected to [{}]", redirectLocation);
knotContext.getClientResponse()
.setStatusCode(HttpResponseStatus.MOVED_PERMANENTLY.code());
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
headers.addAll(getFilteredHeaders(clientResponse.getHeaders(),
form.adapter().getAllowedResponseHeadersPatterns()));
headers.add(HttpHeaders.LOCATION.toString(), redirectLocation);
knotContext.getClientResponse().setHeaders(headers);
knotContext.clearFragments();
return knotContext;
}
代码示例来源:origin: Cognifide/knotx
private String buildRepoUri(ClientRequest repoRequest) {
StringBuilder uri = new StringBuilder(repoRequest.getPath());
MultiMap params = repoRequest.getParams();
if (params != null && params.names() != null && !params.names().isEmpty()) {
uri.append("?")
.append(params.names().stream()
.map(name -> new StringBuilder(encode(name)).append("=")
.append(encode(params.get(name))))
.collect(Collectors.joining("&"))
);
}
return uri.toString();
}
代码示例来源:origin: io.knotx/knotx-core
@GenIgnore
public ClientRequest setParams(MultiMap params) {
this.params = MultiMap.caseInsensitiveMultiMap().addAll(params);
return this;
}
代码示例来源:origin: Cognifide/knotx
private MultiMap getFilteredHeaders(MultiMap headers, List<Pattern> allowedHeaders) {
return headers.names().stream()
.filter(AllowedHeadersFilter.create(allowedHeaders))
.collect(MultiMapCollector.toMultiMap(o -> o, headers::getAll));
}
代码示例来源:origin: io.gravitee.am.gateway/gravitee-am-gateway-reactor
private void sendNotFound(HttpServerResponse serverResponse) {
// Send a NOT_FOUND HTTP status code (404)
serverResponse.setStatusCode(HttpStatusCode.NOT_FOUND_404);
String message = environment.getProperty("http.errors[404].message", "");
serverResponse.headers().set(HttpHeaders.CONTENT_LENGTH, Integer.toString(message.length()));
serverResponse.headers().set(HttpHeaders.CONTENT_TYPE, "text/plain");
serverResponse.headers().set(HttpHeaders.CONNECTION, HttpHeadersValues.CONNECTION_CLOSE);
serverResponse.write(Buffer.buffer(message));
serverResponse.end();
}
代码示例来源:origin: io.gravitee.am.gateway.handlers/gravitee-am-gateway-handler
Map<String, String> approvalParameters = params.getDelegate().entries()
.stream()
.filter(entry -> entry.getKey().startsWith(OAuth2Constants.SCOPE_PREFIX))
.collect(Collectors.toMap(scopeEntry -> scopeEntry.getKey(), scopeEntry -> params.get(OAuth2Constants.USER_OAUTH_APPROVAL)));
authorizationRequest.setApprovalParameters(approvalParameters);
代码示例来源:origin: io.knotx/knotx-core
private Observable<HttpClientResponse> get(HttpClient client, RequestOptions requestOptions,
MultiMap headers) {
return Observable.unsafeCreate(subscriber -> {
HttpClientRequest req = client.get(requestOptions);
req.headers().addAll(headers);
if (headers.get(HttpHeaderNames.HOST.toString()) != null) {
req.setHost(headers.get(HttpHeaderNames.HOST.toString()));
}
Observable<HttpClientResponse> resp = req.toObservable();
resp.subscribe(subscriber);
req.end();
});
}
代码示例来源:origin: Cognifide/knotx
/**
* Method computing hashCode of the give MultiMap.
* MultiMap is treated as a list of key-value pairs where each key is a String and
* the corresponding value is a List of Strings.
*
* @param multiMap - object to compute hashcode from
* @return - hashcode of the given {@link MultiMap} object
*/
public static int multiMapHash(MultiMap multiMap) {
return multiMap.getDelegate().entries().stream().mapToInt(
entry -> 31 * entry.getKey().hashCode() + (entry.getValue() == null ? 0
: entry.getValue().hashCode())
).reduce(0, (sum, hash) -> 41 * sum + hash);
}
代码示例来源:origin: io.knotx/knotx-junit
public static KnotContext create(List<Pair<List<String>, String>> fragments) {
return new KnotContext()
.setFragments(
fragments != null
? fragments.stream().map(data -> Fragment.snippet(data.getKey(), data.getValue())).collect(Collectors.toList())
: null)
.setClientRequest(new ClientRequest())
.setClientResponse(
new ClientResponse()
.setHeaders(MultiMap.caseInsensitiveMultiMap()));
}
代码示例来源:origin: io.gravitee.am.gateway.handlers/gravitee-am-gateway-handler
private MultiValueMap<String, String> extractRequestParameters(HttpServerRequest request) {
MultiValueMap<String, String> requestParameters = new LinkedMultiValueMap<>(request.params().size());
request.params().getDelegate().entries().forEach(entry -> requestParameters.add(entry.getKey(), entry.getValue()));
return requestParameters;
}
代码示例来源:origin: io.knotx/knotx-databridge-adapter-http
public static String encodeBody(final MultiMap formAttributes, Charset charset) {
if (formAttributes == null || formAttributes.isEmpty()) {
return StringUtils.EMPTY;
} else {
Iterator<Entry<String, String>> entryIt = formAttributes
.getDelegate()
.iterator();
StringBuilder sb = new StringBuilder(128);
while (entryIt.hasNext()) {
Entry<String, String> entry = entryIt.next();
sb.append(encodeComponent(entry.getKey(), charset));
if (entry.getValue() != null) {
sb.append('=');
sb.append(encodeComponent(entry.getValue(), charset));
}
if (entryIt.hasNext()) {
sb.append('&');
}
}
return sb.toString();
}
}
代码示例来源:origin: io.knotx.acme/acme-forms-adapter-http
private Single<HttpResponse<Buffer>> callService(
Pair<ClientRequest, HttpFormsSettings> serviceData, HttpMethod method) {
final Single<HttpResponse<Buffer>> httpResponse;
final ClientRequest serviceRequest = serviceData.getLeft();
final HttpFormsSettings serviceMetadata = serviceData.getRight();
final HttpRequest<Buffer> request = webClient
.request(method, serviceMetadata.getPort(), serviceMetadata.getDomain(),
serviceRequest.getPath());
updateRequestQueryParams(request, serviceMetadata);
updateRequestHeaders(request, serviceRequest, serviceMetadata);
overrideRequestHeaders(request, serviceMetadata);
if (!serviceRequest.getFormAttributes().isEmpty()) {
httpResponse = request.rxSendForm(serviceRequest.getFormAttributes());
} else {
httpResponse = request.rxSend();
}
return httpResponse;
}
内容来源于网络,如有侵权,请联系作者删除!