本文整理了Java中io.vertx.reactivex.ext.web.client.HttpRequest.rxSendBuffer()
方法的一些代码示例,展示了HttpRequest.rxSendBuffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.rxSendBuffer()
方法的具体详情如下:
包路径:io.vertx.reactivex.ext.web.client.HttpRequest
类名称:HttpRequest
方法名:rxSendBuffer
暂无
代码示例来源:origin: io.gravitee.elasticsearch/gravitee-common-elasticsearch
/**
* Perform an HTTP search query
* @param indexes indexes names. If null search on all indexes
* @param type document type separated by comma. If null search on all types
* @param query json body query
* @return elasticsearch response
*/
public Single<SearchResponse> search(final String indexes, final String type, final String query) {
// index can be null _search on all index
final StringBuilder url = new StringBuilder()
.append('/')
.append(indexes);
if (type != null) {
url.append('/').append(type);
}
url.append(URL_SEARCH);
return httpClient
.post(url.toString())
.putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.rxSendBuffer(Buffer.buffer(query))
.map(response -> {
if (response.statusCode() != HttpStatusCode.OK_200) {
logger.error("Unable to search: url[{}] status[{}] query[{}] response[{}]",
url.toString(), response.statusCode(), query, response.body());
throw new ElasticsearchException("Unable to search");
}
return mapper.readValue(response.bodyAsString(), SearchResponse.class);
});
}
代码示例来源:origin: io.gravitee.elasticsearch/gravitee-common-elasticsearch
@Override
public Single<BulkResponse> bulk(final List<String> data) {
if (data != null && !data.isEmpty()) {
String content = data.stream().collect(Collectors.joining());
return httpClient
.post(URL_BULK)
.putHeader(HttpHeaders.CONTENT_TYPE, "application/x-ndjson")
.rxSendBuffer(Buffer.buffer(content))
.map(response -> {
if (response.statusCode() != HttpStatusCode.OK_200) {
logger.error("Unable to bulk index data: status[{}] data[{}] response[{}]",
response.statusCode(), content, response.body());
throw new ElasticsearchException("Unable to bulk index data");
}
return mapper.readValue(response.bodyAsString(), BulkResponse.class);
});
}
return Single.never();
}
代码示例来源:origin: io.gravitee.am.identityprovider/gravitee-am-identityprovider-oauth2-generic
private Maybe<String> authenticate(Authentication authentication) {
// prepare body request parameters
List<NameValuePair> urlParameters = new ArrayList<>();
urlParameters.add(new BasicNameValuePair(CLIENT_ID, configuration.getClientId()));
urlParameters.add(new BasicNameValuePair(CLIENT_SECRET, configuration.getClientSecret()));
urlParameters.add(new BasicNameValuePair(REDIRECT_URI, (String) authentication.getAdditionalInformation().get(REDIRECT_URI)));
urlParameters.add(new BasicNameValuePair(CODE, (String) authentication.getCredentials()));
urlParameters.add(new BasicNameValuePair(GRANT_TYPE, "authorization_code"));
String bodyRequest = URLEncodedUtils.format(urlParameters);
return client.postAbs(configuration.getAccessTokenUri())
.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(bodyRequest.length()))
.putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED)
.rxSendBuffer(Buffer.buffer(bodyRequest))
.toMaybe()
.map(httpResponse -> {
if (httpResponse.statusCode() != 200) {
throw new BadCredentialsException(httpResponse.statusMessage());
}
return httpResponse.bodyAsJsonObject().getString("access_token");
});
}
代码示例来源:origin: gravitee-io/graviteeio-access-management
private Maybe<String> authenticate(Authentication authentication) {
// prepare body request parameters
List<NameValuePair> urlParameters = new ArrayList<>();
urlParameters.add(new BasicNameValuePair(CLIENT_ID, configuration.getClientId()));
urlParameters.add(new BasicNameValuePair(CLIENT_SECRET, configuration.getClientSecret()));
urlParameters.add(new BasicNameValuePair(REDIRECT_URI, (String) authentication.getAdditionalInformation().get(REDIRECT_URI)));
urlParameters.add(new BasicNameValuePair(CODE, (String) authentication.getCredentials()));
urlParameters.add(new BasicNameValuePair(GRANT_TYPE, "authorization_code"));
String bodyRequest = URLEncodedUtils.format(urlParameters);
return client.postAbs(configuration.getAccessTokenUri())
.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(bodyRequest.length()))
.putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED)
.rxSendBuffer(Buffer.buffer(bodyRequest))
.toMaybe()
.map(httpResponse -> {
if (httpResponse.statusCode() != 200) {
throw new BadCredentialsException(httpResponse.statusMessage());
}
return httpResponse.bodyAsJsonObject().getString("access_token");
});
}
代码示例来源:origin: io.gravitee.am.identityprovider/gravitee-am-identityprovider-github
private Maybe<String> authenticate(Authentication authentication) {
// prepare body request parameters
List<NameValuePair> urlParameters = new ArrayList<>();
urlParameters.add(new BasicNameValuePair(CLIENT_ID, configuration.getClientId()));
urlParameters.add(new BasicNameValuePair(CLIENT_SECRET, configuration.getClientSecret()));
urlParameters.add(new BasicNameValuePair(REDIRECT_URI, (String) authentication.getAdditionalInformation().get(REDIRECT_URI)));
urlParameters.add(new BasicNameValuePair(CODE, (String) authentication.getCredentials()));
String bodyRequest = URLEncodedUtils.format(urlParameters);
return client.postAbs(configuration.getAccessTokenUri())
.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(bodyRequest.length()))
.putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED)
.rxSendBuffer(Buffer.buffer(bodyRequest))
.toMaybe()
.map(httpResponse -> {
if (httpResponse.statusCode() != 200) {
throw new BadCredentialsException(httpResponse.statusMessage());
}
Map<String, String> bodyResponse = URLEncodedUtils.format(httpResponse.bodyAsString());
return bodyResponse.get("access_token");
});
}
代码示例来源:origin: gravitee-io/graviteeio-access-management
private Maybe<String> authenticate(Authentication authentication) {
// prepare body request parameters
List<NameValuePair> urlParameters = new ArrayList<>();
urlParameters.add(new BasicNameValuePair(CLIENT_ID, configuration.getClientId()));
urlParameters.add(new BasicNameValuePair(CLIENT_SECRET, configuration.getClientSecret()));
urlParameters.add(new BasicNameValuePair(REDIRECT_URI, (String) authentication.getAdditionalInformation().get(REDIRECT_URI)));
urlParameters.add(new BasicNameValuePair(CODE, (String) authentication.getCredentials()));
String bodyRequest = URLEncodedUtils.format(urlParameters);
return client.postAbs(configuration.getAccessTokenUri())
.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(bodyRequest.length()))
.putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED)
.rxSendBuffer(Buffer.buffer(bodyRequest))
.toMaybe()
.map(httpResponse -> {
if (httpResponse.statusCode() != 200) {
throw new BadCredentialsException(httpResponse.statusMessage());
}
Map<String, String> bodyResponse = URLEncodedUtils.format(httpResponse.bodyAsString());
return bodyResponse.get("access_token");
});
}
代码示例来源:origin: io.gravitee.elasticsearch/gravitee-common-elasticsearch
@Override
public Completable putPipeline(String pipelineName, String pipeline) {
return httpClient
.put(URL_INGEST + '/' + pipelineName)
.putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.rxSendBuffer(Buffer.buffer(pipeline))
.flatMapCompletable(response -> {
switch (response.statusCode()) {
case HttpStatusCode.OK_200:
return Completable.complete();
case HttpStatusCode.BAD_REQUEST_400:
logger.warn("Unable to create ES pipeline: {}", pipelineName);
break;
default:
logger.error("Unable to put pipeline: status[{}] pipeline[{}] response[{}]",
response.statusCode(), pipeline, response.body());
break;
}
return Completable.error(new ElasticsearchException("Unable to create ES pipeline: " + pipelineName));
});
}
代码示例来源:origin: io.gravitee.elasticsearch/gravitee-common-elasticsearch
@Override
public Completable putTemplate(String templateName, String template) {
return httpClient
.put(URL_TEMPLATE + '/' + templateName)
.putHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.rxSendBuffer(Buffer.buffer(template))
.flatMapCompletable(response -> {
if (response.statusCode() != HttpStatusCode.OK_200) {
logger.error("Unable to put template mapping: status[{}] template[{}] response[{}]",
response.statusCode(), template, response.body());
return Completable.error(new ElasticsearchException("Unable to put template mapping"));
}
return Completable.complete();
});
}
代码示例来源:origin: com.cv4j.netdiscovery/netdiscovery-core
httpResponseSingle = stringHttpRequest.rxSendBuffer(buffer);
} else {
内容来源于网络,如有侵权,请联系作者删除!