本文整理了Java中org.apache.http.client.fluent.Request.body
方法的一些代码示例,展示了Request.body
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.body
方法的具体详情如下:
包路径:org.apache.http.client.fluent.Request
类名称:Request
方法名:body
暂无
代码示例来源:origin: jooby-project/jooby
public Response expect(final String content) throws Exception {
if (parts != null) {
req.req.body(parts.build());
} else {
req.req.bodyForm(fields);
}
return req.expect(content);
}
代码示例来源:origin: jooby-project/jooby
public Request body(final String body, final String type) {
if (type == null) {
byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
HttpEntity entity = new InputStreamEntity(new ByteArrayInputStream(bytes), bytes.length);
req.body(entity);
} else {
req.bodyString(body, ContentType.parse(type));
}
return this;
}
代码示例来源:origin: org.apache.httpcomponents/fluent-hc
/**
* @since 4.4
*/
public Request bodyByteArray(final byte[] b, final ContentType contentType) {
return body(new InternalByteArrayEntity(b, contentType));
}
代码示例来源:origin: org.apache.httpcomponents/fluent-hc
/**
* @since 4.4
*/
public Request bodyByteArray(final byte[] b, final int off, final int len, final ContentType contentType) {
return body(new InternalByteArrayEntity(b, off, len, contentType));
}
代码示例来源:origin: jooby-project/jooby
public Response expect(final int status) throws Exception {
if (parts != null) {
req.req.body(parts.build());
} else {
req.req.bodyForm(fields);
}
return req.expect(status);
}
代码示例来源:origin: org.apache.httpcomponents/fluent-hc
public Request bodyByteArray(final byte[] b, final int off, final int len) {
return body(new InternalByteArrayEntity(b, off, len));
}
代码示例来源:origin: org.apache.httpcomponents/fluent-hc
public Request bodyStream(final InputStream inStream) {
return body(new InternalInputStreamEntity(inStream, -1, null));
}
代码示例来源:origin: org.apache.httpcomponents/fluent-hc
public Request bodyStream(final InputStream inStream, final ContentType contentType) {
return body(new InternalInputStreamEntity(inStream, -1, contentType));
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient
public Request bodyFile(final File file, final ContentType contentType) {
return body(new InternalFileEntity(file, contentType));
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient
public Request bodyByteArray(final byte[] b, final int off, final int len) {
return body(new InternalByteArrayEntity(b, off, len));
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient
public Request bodyStream(final InputStream instream) {
return body(new InternalInputStreamEntity(instream, -1, null));
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient
public Request bodyStream(final InputStream instream, final ContentType contentType) {
return body(new InternalInputStreamEntity(instream, -1, contentType));
}
代码示例来源:origin: org.apache.httpcomponents/fluent-hc
public Request bodyFile(final File file, final ContentType contentType) {
return body(new InternalFileEntity(file, contentType));
}
代码示例来源:origin: org.apache.httpcomponents/fluent-hc
public Request bodyByteArray(final byte[] b) {
return body(new InternalByteArrayEntity(b));
}
代码示例来源:origin: org.apache.httpcomponents/fluent-hc
public Request bodyString(final String s, final ContentType contentType) {
final Charset charset = contentType != null ? contentType.getCharset() : null;
final byte[] raw = charset != null ? s.getBytes(charset) : s.getBytes();
return body(new InternalByteArrayEntity(raw, contentType));
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient
public Request bodyString(final String s, final ContentType contentType) {
final Charset charset = contentType != null ? contentType.getCharset() : null;
byte[] raw;
try {
raw = charset != null ? s.getBytes(charset.name()) : s.getBytes();
} catch (UnsupportedEncodingException ex) {
raw = s.getBytes();
}
return body(new InternalByteArrayEntity(raw, contentType));
}
代码示例来源:origin: org.streampipes/streampipes-pipeline-management
private Integer createConsumer(String kafkaRestUrl, String consumerInstance, String topic) throws IOException {
String createConsumerUrl = kafkaRestUrl + "/consumers/" + getConsumerGroupId(topic);
return Request.Post(createConsumerUrl)
.addHeader(HttpHeaders.CONTENT_TYPE, KAFKA_REST_CONTENT_TYPE)
.addHeader(HttpHeaders.ACCEPT, KAFKA_REST_CONTENT_TYPE)
.body(new StringEntity(makeCreateConsumerBody(consumerInstance), Charsets.UTF_8))
.execute()
.returnResponse()
.getStatusLine()
.getStatusCode();
}
代码示例来源:origin: streampipes/streampipes-ce
private Integer createConsumer(String kafkaRestUrl, String consumerInstance, String topic) throws IOException {
String createConsumerUrl = kafkaRestUrl + "/consumers/" + getConsumerGroupId(topic);
return Request.Post(createConsumerUrl)
.addHeader(HttpHeaders.CONTENT_TYPE, KAFKA_REST_CONTENT_TYPE)
.addHeader(HttpHeaders.ACCEPT, KAFKA_REST_CONTENT_TYPE)
.body(new StringEntity(makeCreateConsumerBody(consumerInstance), Charsets.UTF_8))
.execute()
.returnResponse()
.getStatusLine()
.getStatusCode();
}
代码示例来源:origin: org.streampipes/streampipes-pipeline-management
private Integer subscribeConsumer(String kafkaRestUrl, String consumerInstance, String kafkaTopic) throws IOException {
String subscribeConsumerUrl = getConsumerInstanceUrl(kafkaRestUrl, consumerInstance, kafkaTopic)
+ "/subscription";
return Request.Post(subscribeConsumerUrl)
.addHeader(HttpHeaders.CONTENT_TYPE, KAFKA_REST_CONTENT_TYPE)
.addHeader(HttpHeaders.ACCEPT, KAFKA_REST_CONTENT_TYPE)
.body(new StringEntity(makeSubscribeConsumerBody(kafkaTopic), Charsets.UTF_8))
.execute()
.returnResponse()
.getStatusLine()
.getStatusCode();
}
代码示例来源:origin: streampipes/streampipes-ce
private Integer subscribeConsumer(String kafkaRestUrl, String consumerInstance, String kafkaTopic) throws IOException {
String subscribeConsumerUrl = getConsumerInstanceUrl(kafkaRestUrl, consumerInstance, kafkaTopic)
+ "/subscription";
return Request.Post(subscribeConsumerUrl)
.addHeader(HttpHeaders.CONTENT_TYPE, KAFKA_REST_CONTENT_TYPE)
.addHeader(HttpHeaders.ACCEPT, KAFKA_REST_CONTENT_TYPE)
.body(new StringEntity(makeSubscribeConsumerBody(kafkaTopic), Charsets.UTF_8))
.execute()
.returnResponse()
.getStatusLine()
.getStatusCode();
}
内容来源于网络,如有侵权,请联系作者删除!