Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.10.1 backports 3 #26419

Merged
merged 2 commits into from Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Expand Up @@ -46,7 +46,7 @@
<smallrye-open-api.version>2.1.22</smallrye-open-api.version>
<smallrye-graphql.version>1.6.0</smallrye-graphql.version>
<smallrye-opentracing.version>2.1.0</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>5.4.0</smallrye-fault-tolerance.version>
<smallrye-fault-tolerance.version>5.4.1</smallrye-fault-tolerance.version>
<smallrye-jwt.version>3.5.1</smallrye-jwt.version>
<smallrye-context-propagation.version>1.2.2</smallrye-context-propagation.version>
<smallrye-reactive-streams-operators.version>1.0.13</smallrye-reactive-streams-operators.version>
Expand Down
10 changes: 10 additions & 0 deletions docs/src/main/asciidoc/http-reference.adoc
Expand Up @@ -245,6 +245,16 @@ Will include the `Cache-Control: max-age=1` header when `/paths/order` is reques

include::{generated-dir}/config/quarkus-vertx-http-config-group-filter-config.adoc[leveloffset=+1, opts=optional]

== Support 100-Continue in vert.x

In order to support `100-continue`, the `quarkus.http.handle-100-continue-automatically` option needs to be enabled explicitly
For additional information check https://datatracker.ietf.org/doc/html/rfc7231#section-5.1.1[100-continue= and the related
https://vertx.io/docs/apidocs/io/vertx/core/http/HttpServerOptions.html#DEFAULT_HANDLE_100_CONTINE_AUTOMATICALLY[Vert.x documentation].

[source,properties]
----
quarkus.http.handle-100-continue-automatically=true
----

== HTTP/2 Support

Expand Down
Expand Up @@ -24,6 +24,7 @@
import io.quarkus.gizmo.ClassOutput;
import io.smallrye.common.annotation.Blocking;
import io.smallrye.common.annotation.NonBlocking;
import io.smallrye.faulttolerance.api.ApplyFaultTolerance;
import io.smallrye.faulttolerance.api.CircuitBreakerName;
import io.smallrye.faulttolerance.api.CustomBackoff;
import io.smallrye.faulttolerance.api.ExponentialBackoff;
Expand Down Expand Up @@ -119,6 +120,7 @@ FaultToleranceMethod createFaultToleranceMethod(ClassInfo beanClass, MethodInfo
result.retry = getAnnotation(Retry.class, method, beanClass, annotationsPresentDirectly);
result.timeout = getAnnotation(Timeout.class, method, beanClass, annotationsPresentDirectly);

result.applyFaultTolerance = getAnnotation(ApplyFaultTolerance.class, method, beanClass, annotationsPresentDirectly);
result.circuitBreakerName = getAnnotation(CircuitBreakerName.class, method, beanClass, annotationsPresentDirectly);
result.customBackoff = getAnnotation(CustomBackoff.class, method, beanClass, annotationsPresentDirectly);
result.exponentialBackoff = getAnnotation(ExponentialBackoff.class, method, beanClass, annotationsPresentDirectly);
Expand Down
@@ -0,0 +1,67 @@
package io.quarkus.vertx.http;

import java.net.Socket;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;

import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.quarkus.test.common.http.TestHTTPResource;
import io.vertx.core.Handler;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;

public class HttpContinueHeaderTest {
private static final String APP_PROPS = "quarkus.http.handle-100-continue-automatically=true\n";

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addAsResource(new StringAsset(APP_PROPS), "application.properties")
.addClasses(HttpContinueHeaderTest.BeanRegisteringRouteUsingObserves.class));

@TestHTTPResource
URL uri;

@Test
public void testConnection() throws Exception {
try (Socket one = new Socket(uri.getHost(), uri.getPort())) {
one.getOutputStream().write("GET /hello HTTP/1.1\r\nExpect: 100-continue\r\nHost: localhost\r\n\r\n"
.getBytes(StandardCharsets.UTF_8));

StringBuilder sb = new StringBuilder();
byte[] data = new byte[1024];
int j;
while (!sb.toString().endsWith("hello")) {
j = one.getInputStream().read(data);
if (j == -1) {
Assertions.fail("Did not read full HTTP response");
}
sb.append(new String(data, 0, j, StandardCharsets.US_ASCII));
}
Assertions.assertTrue(sb.toString().contains("HTTP/1.1 100 Continue"));
Assertions.assertTrue(sb.toString().contains("HTTP/1.1 200 OK"));
}
}

@ApplicationScoped
static class BeanRegisteringRouteUsingObserves {

public void register(@Observes Router router) {
router.route("/hello").handler(new Handler<RoutingContext>() {
@Override
public void handle(RoutingContext event) {
event.end("hello");
}
});

}
}
}
Expand Up @@ -91,6 +91,13 @@ public class HttpConfiguration {
*/
public ServerSslConfig ssl;

/**
* When set to {@code true}, the HTTP server automatically sends `100 CONTINUE`
* response when the request expects it (with the `Expect: 100-Continue` header).
*/
@ConfigItem(defaultValue = "false", name = "handle-100-continue-automatically")
public boolean handle100ContinueAutomatically;

/**
* The number if IO threads used to perform IO. This will be automatically set to a reasonable value based on
* the number of CPU cores if it is not provided. If this is set to a higher value than the number of Vert.x event
Expand Down
Expand Up @@ -861,6 +861,7 @@ private static void applyCommonOptions(HttpServerOptions httpServerOptions,
}
httpServerOptions.setDecompressionSupported(buildTimeConfig.enableDecompression);
httpServerOptions.setMaxInitialLineLength(httpConfiguration.limits.maxInitialLineLength);
httpServerOptions.setHandle100ContinueAutomatically(httpConfiguration.handle100ContinueAutomatically);
}

private static KeyStoreOptions createKeyStoreOptions(Path path, String password, Optional<String> fileType,
Expand Down