本文整理了Java中com.atlassian.httpclient.api.HttpClient.newRequest()
方法的一些代码示例,展示了HttpClient.newRequest()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.newRequest()
方法的具体详情如下:
包路径:com.atlassian.httpclient.api.HttpClient
类名称:HttpClient
方法名:newRequest
[英]Constructs a new request. Sets the accept property to a default of "/".
[中]构造一个新请求。将accept属性设置为默认值“/”。
代码示例来源:origin: com.atlassian.plugins/atlassian-connect-core
@Override
public Promise<Response> asyncWithCache(@Nonnull AuthorizationGenerator authorizationGenerator,
@Nonnull HttpMethod method,
@Nonnull URI url,
@Nonnull Map<String, String[]> parameters,
@Nonnull Map<String, String> headers,
@Nonnull InputStream body,
@Nonnull String addonKey) {
Request.Builder request = httpClient.newRequest(getFullUrl(method, url, parameters));
return async(authorizationGenerator, method, url, parameters, headers, body, addonKey, request);
}
代码示例来源:origin: com.atlassian.plugins/atlassian-connect-core
@Override
public Promise<Response> asyncWithoutCache(@Nonnull AuthorizationGenerator authorizationGenerator,
@Nonnull HttpMethod method,
@Nonnull URI url,
@Nonnull Map<String, String[]> parameters,
@Nonnull Map<String, String> headers,
@Nonnull InputStream body,
@Nonnull String addonKey) {
Request.Builder request = httpClient.newRequest(getFullUrl(method, url, parameters));
request.setCacheDisabled();
return async(authorizationGenerator, method, url, parameters, headers, body, addonKey, request);
}
代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core
@Override
public Promise<InputStream> getAttachment(URI attachmentUri) {
return callAndParse(client().newRequest(attachmentUri).get(),
new ResponseHandler<InputStream>() {
@Override
public InputStream handle(final Response request) throws JSONException, IOException {
return request.getEntityStream();
}
}
);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
protected final <T> Promise<Void> put(final URI uri, final T entity, final JsonGenerator<T> jsonGenerator) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(toEntity(jsonGenerator, entity))
.put();
return call(responsePromise);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
protected final Promise<Void> post(final URI uri, final String entity) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(entity)
.setContentType(JSON_CONTENT_TYPE)
.post();
return call(responsePromise);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
protected final <T> Promise<Void> post(final URI uri, final T entity, final JsonGenerator<T> jsonGenerator) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(toEntity(jsonGenerator, entity))
.post();
return call(responsePromise);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
protected final <I, T> Promise<T> putAndParse(final URI uri, I entity, final JsonGenerator<I> jsonGenerator,
final JsonObjectParser<T> parser) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(toEntity(jsonGenerator, entity))
.put();
return callAndParse(responsePromise, parser);
}
代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core
protected final Promise<Void> post(final URI uri, final String entity) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(entity)
.setContentType(JSON_CONTENT_TYPE)
.post();
return call(responsePromise);
}
代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core
protected final <I, T> Promise<T> putAndParse(final URI uri, I entity, final JsonGenerator<I> jsonGenerator,
final JsonObjectParser<T> parser) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(toEntity(jsonGenerator, entity))
.put();
return callAndParse(responsePromise, parser);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
protected final <I, T> Promise<T> postAndParse(final URI uri, I entity, final JsonGenerator<I> jsonGenerator,
final JsonObjectParser<T> parser) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(toEntity(jsonGenerator, entity))
.post();
return callAndParse(responsePromise, parser);
}
代码示例来源:origin: com.atlassian.plugins/atlassian-connect-core
private DownloadResult<ResponsePromise> scheduleDownload(Language language, String baseUrl, String path) {
URI uriToDownload = resolveUri(baseUrl, path);
ResponsePromise responsePromise = httpClient
.newRequest(uriToDownload)
.setAccept(MediaType.APPLICATION_JSON)
.get();
return new DownloadResult<>(language, uriToDownload, responsePromise);
}
代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core
protected final <I, T> Promise<T> postAndParse(final URI uri, I entity, final JsonGenerator<I> jsonGenerator,
final JsonObjectParser<T> parser) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(toEntity(jsonGenerator, entity))
.post();
return callAndParse(responsePromise, parser);
}
代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core
protected final <T> Promise<Void> post(final URI uri, final T entity, final JsonGenerator<T> jsonGenerator) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(toEntity(jsonGenerator, entity))
.post();
return call(responsePromise);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
private Promise<Void> postAttachments(final URI attachmentsUri, final MultipartEntityBuilder multipartEntityBuilder) {
final ResponsePromise responsePromise = client()
.newRequest(attachmentsUri)
.setEntity(new MultiPartEntityBuilder(multipartEntityBuilder.build()))
.setHeader("X-Atlassian-Token", "nocheck")
.post();
return call(responsePromise);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
protected final <T> Promise<T> postAndParse(final URI uri, final JSONObject entity, final JsonObjectParser<T> parser) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(entity.toString())
.setContentType(JSON_CONTENT_TYPE)
.post();
return callAndParse(responsePromise, parser);
}
代码示例来源:origin: org.openengsb.wrapped/jira-rest-java-client-core
protected final <T> Promise<T> postAndParse(final URI uri, final JSONObject entity, final JsonObjectParser<T> parser) {
final ResponsePromise responsePromise = client.newRequest(uri)
.setEntity(entity.toString())
.setContentType(JSON_CONTENT_TYPE)
.post();
return callAndParse(responsePromise, parser);
}
代码示例来源:origin: com.atlassian.hipchat.plugins/hipchat-core-plugin
@Override
public Promise<Either<ClientError, List<User>>> list()
{
return httpClient.newRequest("/users/list").get().<Either<ClientError, List<User>>>transform()
.ok(parseJson("users", new TypeReference<List<User>>(){}))
.others(ClientUtils.<List<User>>error())
.fail(ClientUtils.<List<User>>throwable())
.toPromise();
}
}
代码示例来源:origin: com.atlassian.hipchat.plugins/hipchat-core-plugin
@Override
public Promise<Either<ClientError, List<Room>>> list()
{
return httpClient.newRequest("/rooms/list").get().<Either<ClientError, List<Room>>>transform()
.ok(parseJson("rooms", new TypeReference<List<Room>>(){}))
.others(ClientUtils.<List<Room>>error())
.fail(ClientUtils.<List<Room>>throwable())
.toPromise();
}
代码示例来源:origin: com.atlassian.hipchat.plugins/hipchat-core-plugin
@Override
public Promise<Either<ClientError, Status>> message(String roomIdOrName, String from, String message, Option<Message.Format> format, Option<Message.BackgroundColor> color, Option<Boolean> notify)
{
// TODO: validate params
final Map<String, String> params = messageParametersAsMap(roomIdOrName, from, message, format, color, notify);
return httpClient.newRequest("/rooms/message", "application/x-www-form-urlencoded", urlEncode(params))
.post().<Either<ClientError, Status>>transform()
.ok(constantRight(Status.SENT))
.others(ClientUtils.<Status>error())
.fail(ClientUtils.<Status>throwable())
.toPromise();
}
代码示例来源:origin: com.atlassian.hipchat.plugins/hipchat-core-plugin
@Override
public Promise<Either<ClientError, Room>> create(String name, long ownerId, Option<Boolean> privacy, Option<String> topic, Option<Boolean> enableGuestAccess)
{
// TODO validate params
final Map<String, String> params = createParametersAsMap(name, ownerId, privacy, topic, enableGuestAccess);
return httpClient.newRequest("/rooms/create", "application/x-www-form-urlencoded", urlEncode(params))
.post().<Either<ClientError, Room>>transform()
.ok(parseJson("room", Room.class))
.others(ClientUtils.<Room>error())
.fail(ClientUtils.<Room>throwable())
.toPromise();
}
内容来源于网络,如有侵权,请联系作者删除!