本文整理汇总了Java中io.vertx.core.http.CaseInsensitiveHeaders类的典型用法代码示例。如果您正苦于以下问题:Java CaseInsensitiveHeaders类的具体用法?Java CaseInsensitiveHeaders怎么用?Java CaseInsensitiveHeaders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CaseInsensitiveHeaders类属于io.vertx.core.http包,在下文中一共展示了CaseInsensitiveHeaders类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testFailureHandler
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test
public void testFailureHandler() throws Exception {
RoutingContext rc = mock(RoutingContext.class);
Route currentRoute = mock(RouteImpl.class);
when(currentRoute.getPath()).thenReturn("/blub");
when(rc.currentRoute()).thenReturn(currentRoute);
ParsedHeaderValues headerValues = mock(ParsedHeaderValues.class);
when(rc.parsedHeaders()).thenReturn(headerValues);
HttpServerRequest request = mock(HttpServerRequest.class);
when(request.query()).thenReturn("?blub");
when(request.method()).thenReturn(HttpMethod.GET);
when(request.uri()).thenReturn("");
when(rc.request()).thenReturn(request);
when(rc.normalisedPath()).thenReturn("/blub");
when(rc.queryParams()).thenReturn(new CaseInsensitiveHeaders());
storage.getRootRouter().handleFailure(rc);
}
开发者ID:gentics,项目名称:mesh,代码行数:18,代码来源:RouterStorageTest.java
示例2: testHandlerCase2
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test
public void testHandlerCase2() throws IOException {
File uploadFolder = getUploadFolder();
try (Tx tx = tx()) {
// Setup the schema & request
prepareSchema(content(), null, "binaryField");
CaseInsensitiveHeaders attributes = new CaseInsensitiveHeaders();
attributes.add("language", "en");
attributes.add("version", "1.0");
InternalActionContext ac = mockContext(mockUpload("blub123"));
// Assert initial condition
assertFalse("Initially no upload folder should exist.", uploadFolder.exists());
// Invoke the request
handler.handleUpdateField(ac, contentUuid(), "binaryField", attributes);
// Assert result
assertThat(uploadFolder).as("The upload folder should have been created").exists();
}
}
开发者ID:gentics,项目名称:mesh,代码行数:22,代码来源:BinaryFieldHandlerTest.java
示例3: testFileUploadWithNoUploadFile
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test(expected = GenericRestException.class)
public void testFileUploadWithNoUploadFile() throws Throwable {
try (Tx tx = tx()) {
// Setup the schema & request
prepareSchema(content(), null, "binaryField");
FileUpload upload = mockUpload("blub123");
InternalActionContext ac = mockContext(upload);
CaseInsensitiveHeaders attributes = new CaseInsensitiveHeaders();
attributes.add("language", "en");
attributes.add("version", "1.0");
// Delete the file on purpose in order to invoke an error
new File(upload.uploadedFileName()).delete();
// Invoke the request
handler.handleUpdateField(ac, contentUuid(), "binaryField", attributes);
}
}
开发者ID:gentics,项目名称:mesh,代码行数:19,代码来源:BinaryFieldHandlerTest.java
示例4: HttpPart
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
public HttpPart(Buffer bodyBuffer) {
this.buffer = Buffer.buffer();
List<String> headersList = new ArrayList<>();
// We need to extract headers and content from buffer
RecordParser parser = RecordParser.newDelimited("\r\n", new Handler<Buffer>() {
int pos = 0;
boolean startContent = false;
@Override
public void handle(Buffer frame) {
if (frame.length() == 0) {
if (pos > 0) {
startContent = true;
}
} else {
if (!startContent) {
headersList.add(frame.toString().trim());
} else {
buffer.appendBuffer(frame);
}
}
pos++;
}
});
parser.handle(bodyBuffer);
this.headers = new CaseInsensitiveHeaders();
for (String header : headersList) {
int offset = header.indexOf(":");
this.headers.add(header.substring(0, offset), header.substring(offset + 1).trim());
}
this.contentType = HttpUtils.extractContentType(headers);
this.contentDisposition = HttpUtils.extractContentDisposition(headers);
}
开发者ID:etourdot,项目名称:vertx-marklogic,代码行数:36,代码来源:HttpPart.java
示例5: RestClientOptions
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
public RestClientOptions(final JsonObject json) {
super(json);
final JsonObject jsonObjectGlobalRequestCacheOptions = json.getJsonObject("globalRequestCacheOptions");
if (jsonObjectGlobalRequestCacheOptions != null) {
final RequestCacheOptions requestCacheOptions = new RequestCacheOptions();
final Integer ttlInMillis = jsonObjectGlobalRequestCacheOptions.getInteger("ttlInMillis");
final Boolean evictBefore = jsonObjectGlobalRequestCacheOptions.getBoolean("evictBefore");
if (jsonObjectGlobalRequestCacheOptions.getJsonArray("cachedStatusCodes") != null) {
final Set<Integer> cachedStatusCodes = jsonObjectGlobalRequestCacheOptions.getJsonArray("cachedStatusCodes")
.stream()
.map(e -> (Integer) e)
.collect(Collectors.toSet());
requestCacheOptions.withCachedStatusCodes(cachedStatusCodes);
}
if (ttlInMillis != null) {
requestCacheOptions.withExpiresAfterWriteMillis(ttlInMillis);
}
if (evictBefore != null) {
requestCacheOptions.withEvictBefore(evictBefore);
}
globalRequestCacheOptions = requestCacheOptions;
}
globalHeaders = new CaseInsensitiveHeaders();
globalRequestTimeoutInMillis = json.getLong("globalRequestTimeoutInMillis", DEFAULT_GLOBAL_REQUEST_TIMEOUT_IN_MILLIS);
}
开发者ID:hubrick,项目名称:vertx-rest-client,代码行数:27,代码来源:RestClientOptions.java
示例6: MultiPart
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
public MultiPart(List<EncodedPart> parts, String mode) {
String boundary = Utils.generateBoundary();
headers = new CaseInsensitiveHeaders();
headers.set("Content-Type", "multipart/" + mode + "; boundary=\"" + boundary + "\"");
StringBuilder sb = new StringBuilder();
for (EncodedPart part : parts) {
sb.append("--");
sb.append(boundary);
sb.append('\n');
sb.append(part.asString());
sb.append("\n\n");
}
sb.append("--");
sb.append(boundary);
sb.append("--");
part = sb.toString();
}
开发者ID:vert-x3,项目名称:vertx-mail-client,代码行数:22,代码来源:MultiPart.java
示例7: MailMessage
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
/**
* copy object to another @link MailMessage object
*
* @param other object to copy
*/
public MailMessage(MailMessage other) {
Objects.requireNonNull(other);
this.bounceAddress = other.bounceAddress;
this.from = other.from;
this.to = copyList(other.to);
this.cc = copyList(other.cc);
this.bcc = copyList(other.bcc);
this.subject = other.subject;
this.text = other.text;
this.html = other.html;
if (other.attachment != null) {
this.attachment = copyAttachments(other.attachment);
}
if (other.inlineAttachment != null) {
this.inlineAttachment = copyAttachments(other.inlineAttachment);
}
if (other.headers != null) {
headers = new CaseInsensitiveHeaders().addAll(other.headers);
}
}
开发者ID:vert-x3,项目名称:vertx-mail-client,代码行数:26,代码来源:MailMessage.java
示例8: testFixedHeadersMultiple
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test
public void testFixedHeadersMultiple() {
MailMessage message = new MailMessage();
final MultiMap headers = new CaseInsensitiveHeaders();
headers.add("Header", "value1");
headers.add("Header", "value2");
headers.add("Header2", "value3");
headers.add("Header", "value4");
message.setHeaders(headers);
message.setFixedHeaders(true);
message.setText("message text");
String mime = new MailEncoder(message, HOSTNAME).encode();
assertEquals("Header: value1\n" +
"Header: value2\n" +
"Header2: value3\n" +
"Header: value4\n" +
"\n" +
"message text", TestUtils.conv2nl(mime));
}
开发者ID:vert-x3,项目名称:vertx-mail-client,代码行数:20,代码来源:MailEncoderTest.java
示例9: testExternalAuthProviderFails
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test
public void testExternalAuthProviderFails(TestContext context) throws Exception {
AtomicInteger count = new AtomicInteger();
AuthProvider authProvider = (authInfo, resultHandler) -> {
count.incrementAndGet();
resultHandler.handle(Future.failedFuture("not authenticated"));
};
Async async = context.async();
server = createServer(context, new HttpTermOptions().setPort(8080));
server.authProvider(authProvider);
server.termHandler(term -> {
context.fail();
});
server.listen(context.asyncAssertSuccess(server -> {
HttpClient client = vertx.createHttpClient();
client.websocket(8080, "localhost", basePath + "/shell/websocket", new CaseInsensitiveHeaders().add("Authorization", "Basic " + Base64.getEncoder().encodeToString("paulo:anothersecret".getBytes())), ws -> {
context.fail();
}, err -> {
assertEquals(1, count.get());
async.complete();
});
}));
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:24,代码来源:HttpTermServerBase.java
示例10: testDifferentCharset
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test
public void testDifferentCharset(TestContext context) throws Exception {
Async async = context.async();
server = createServer(context, new HttpTermOptions().setPort(8080).setCharset("ISO_8859_1"));
server.termHandler(term -> {
term.write("\u20AC");
term.close();
});
server.listen(context.asyncAssertSuccess(server -> {
HttpClient client = vertx.createHttpClient();
client.websocket(8080, "localhost", basePath + "/shell/websocket", new CaseInsensitiveHeaders().add("Authorization", "Basic " + Base64.getEncoder().encodeToString("paulo:anothersecret".getBytes())), ws -> {
ws.handler(buf -> {
context.assertTrue(Arrays.equals(new byte[]{63}, buf.getBytes()));
async.complete();
});
}, context::fail);
}));
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:19,代码来源:HttpTermServerBase.java
示例11: testKeymapFromFilesystem
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test
public void testKeymapFromFilesystem(TestContext context) throws Exception {
URL url = TermServer.class.getResource(SSHTermOptions.DEFAULT_INPUTRC);
File f = new File(url.toURI());
Async async = context.async();
server = createServer(context, new HttpTermOptions().setPort(8080).setIntputrc(f.getAbsolutePath()));
server.termHandler(term -> {
term.close();
async.complete();
});
server.listen(context.asyncAssertSuccess(server -> {
HttpClient client = vertx.createHttpClient();
client.websocket(8080, "localhost", basePath + "/shell/websocket", new CaseInsensitiveHeaders().add("Authorization", "Basic " + Base64.getEncoder().encodeToString("paulo:anothersecret".getBytes())), ws -> {
ws.handler(buf -> {
});
}, context::fail);
}));
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:19,代码来源:HttpTermServerBase.java
示例12: HttpRequestImpl
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
HttpRequestImpl(WebClientImpl client, HttpMethod method, String protocol, boolean ssl, int port, String host, String
uri, BodyCodec<T> codec, WebClientOptions options) {
this.client = client;
this.method = method;
this.protocol = protocol;
this.codec = codec;
this.port = port;
this.host = host;
this.uri = uri;
this.ssl = ssl;
this.followRedirects = options.isFollowRedirects();
this.options = options;
if (options.isUserAgentEnabled()) {
headers = new CaseInsensitiveHeaders().add(HttpHeaders.USER_AGENT, options.getUserAgent());
}
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:17,代码来源:HttpRequestImpl.java
示例13: testAfterReceiveResponseNormal
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test
public void testAfterReceiveResponseNormal(@Mocked Invocation invocation,
@Mocked HttpServletResponseEx responseEx,
@Mocked Buffer bodyBuffer,
@Mocked OperationMeta operationMeta,
@Mocked ResponseMeta responseMeta,
@Mocked RestOperationMeta swaggerRestOperation,
@Mocked ProduceProcessor produceProcessor) throws Exception {
MultiMap responseHeader = new CaseInsensitiveHeaders();
responseHeader.add("b", "bValue");
Object decodedResult = new Object();
new Expectations() {
{
responseEx.getHeader(HttpHeaders.CONTENT_TYPE);
result = "json";
responseEx.getHeaderNames();
result = Arrays.asList("a", "b");
responseEx.getHeaders("b");
result = responseHeader.getAll("b");
swaggerRestOperation.findProduceProcessor("json");
result = produceProcessor;
produceProcessor.decodeResponse(bodyBuffer, responseMeta.getJavaType());
result = decodedResult;
invocation.getOperationMeta();
result = operationMeta;
operationMeta.getExtData(RestConst.SWAGGER_REST_OPERATION);
result = swaggerRestOperation;
responseEx.getStatusType();
result = Status.OK;
}
};
Response response = filter.afterReceiveResponse(invocation, responseEx);
Assert.assertSame(decodedResult, response.getResult());
Assert.assertEquals(1, response.getHeaders().getHeaderMap().size());
Assert.assertEquals(response.getHeaders().getHeader("b"), Arrays.asList("bValue"));
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:41,代码来源:TestDefaultHttpClientFilter.java
示例14: generate
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Override
public MultiMap generate(RoutingContext context) {
CaseInsensitiveHeaders headers = new CaseInsensitiveHeaders();
context.request().headers().entries().stream()
.filter(entry -> entry.getKey().startsWith(headerPrefix))
.forEach(entry -> headers.set(entry.getKey().substring(headerPrefix.length()), entry.getValue()));
return headers;
}
开发者ID:codefacts,项目名称:Elastic-Components,代码行数:12,代码来源:MessageHeaderGeneratorImpl.java
示例15: constructHttpPart
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
private static HttpPart constructHttpPart(Document document, Buffer buffer, String mimeType) {
HttpPart contentHttpPart = new HttpPart();
MultiMap headers = new CaseInsensitiveHeaders();
if (mimeType != null) {
headers.add(HttpHeaders.CONTENT_TYPE, mimeType);
} else {
headers.add(HttpHeaders.CONTENT_TYPE, Format.JSON.getDefaultMimetype());
}
headers.add(HttpHeaders.CONTENT_LENGTH, Integer.toString(buffer.length()));
headers.add(HttpUtils.HEADER_CONTENT_DISPOSITION, computeContentDisposition(document, mimeType != null));
contentHttpPart.headers(headers).buffer(buffer);
return contentHttpPart;
}
开发者ID:etourdot,项目名称:vertx-marklogic,代码行数:14,代码来源:DefaultMultiPartRequest.java
示例16: MailAttachment
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
/**
* create a copy of a MailAttachment object
*
* @param other object to be copied
*/
public MailAttachment(final MailAttachment other) {
Objects.requireNonNull(other);
this.data = other.data == null ? null : other.data.copy();
this.name = other.name;
this.contentType = other.contentType;
this.disposition = other.disposition;
this.description = other.description;
this.description = other.description;
this.contentId = other.contentId;
this.headers = other.headers == null ? null : new CaseInsensitiveHeaders().addAll(other.headers);
}
开发者ID:vert-x3,项目名称:vertx-mail-client,代码行数:17,代码来源:MailAttachment.java
示例17: createHeaders
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
/**
* create the headers of the MIME message by combining the headers the user has supplied with the ones necessary for
* the message
*
* @return MultiMap of final headers
*/
private MultiMap createHeaders(MultiMap additionalHeaders) {
MultiMap headers = new CaseInsensitiveHeaders();
if (!message.isFixedHeaders()) {
headers.set("MIME-Version", "1.0");
headers.set("Message-ID", Utils.generateMessageID(hostname));
headers.set("Date", Utils.generateDate());
if (message.getSubject() != null) {
headers.set("Subject", Utils.encodeHeader(message.getSubject(), 9));
}
if (message.getFrom() != null) {
headers.set("From", Utils.encodeHeaderEmail(message.getFrom(), 6));
}
if (message.getTo() != null) {
headers.set("To", Utils.encodeEmailList(message.getTo(), 4));
}
if (message.getCc() != null) {
headers.set("Cc", Utils.encodeEmailList(message.getCc(), 4));
}
headers.addAll(additionalHeaders);
}
// add the user-supplied headers as last step, this way it is possible
// to supply a custom Message-ID for example.
MultiMap headersToSet = message.getHeaders();
if (headersToSet != null) {
for (String key : headersToSet.names()) {
headers.remove(key);
}
headers.addAll(headersToSet);
}
messageID = headers.get("Message-ID");
return headers;
}
开发者ID:vert-x3,项目名称:vertx-mail-client,代码行数:46,代码来源:MailEncoder.java
示例18: jsonToMultiMap
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
static MultiMap jsonToMultiMap(final JsonObject jsonHeaders) {
MultiMap headers = new CaseInsensitiveHeaders();
for (String key : jsonHeaders.getMap().keySet()) {
headers.add(key, getKeyAsStringOrList(jsonHeaders, key));
}
return headers;
}
开发者ID:vert-x3,项目名称:vertx-mail-client,代码行数:8,代码来源:Utils.java
示例19: testConstructorFromClassHeaders
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test
public void testConstructorFromClassHeaders() {
MailMessage message = new MailMessage();
message.setHeaders(new CaseInsensitiveHeaders());
MailMessage message2 = new MailMessage(message);
// cannot use equals since CaseInsensitiveHeaders doesn't implement that
assertEquals(message.toJson().encode(), message2.toJson().encode());
}
开发者ID:vert-x3,项目名称:vertx-mail-client,代码行数:9,代码来源:MailMessageTest.java
示例20: testHeadersEmpty
import io.vertx.core.http.CaseInsensitiveHeaders; //导入依赖的package包/类
@Test
public void testHeadersEmpty() {
MailMessage mailMessage = new MailMessage();
MultiMap headers = new CaseInsensitiveHeaders();
mailMessage.setHeaders(headers);
assertEquals(0, mailMessage.getHeaders().size());
assertEquals("{\"headers\":{}}", mailMessage.toJson().encode());
}
开发者ID:vert-x3,项目名称:vertx-mail-client,代码行数:9,代码来源:MailMessageTest.java
注:本文中的io.vertx.core.http.CaseInsensitiveHeaders类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论