Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package docs.http.javadsl;

import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.ServerBinding;
import org.apache.pekko.http.javadsl.model.HttpCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package docs.http.javadsl;

import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.ConnectionContext;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.ServerBinding;
Expand Down
23 changes: 12 additions & 11 deletions docs/src/test/java/docs/http/javadsl/HttpClientExampleDocTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,34 @@
import org.apache.pekko.Done;
import org.apache.pekko.NotUsed;
import org.apache.pekko.actor.*;
import org.apache.pekko.http.javadsl.ClientTransport;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.OutgoingConnection;
import org.apache.pekko.http.javadsl.model.headers.HttpCredentials;
import org.apache.pekko.http.javadsl.model.headers.SetCookie;
import org.apache.pekko.util.ByteString;
import scala.concurrent.ExecutionContextExecutor;
import org.apache.pekko.stream.javadsl.*;
import org.apache.pekko.http.javadsl.ClientTransport;
import org.apache.pekko.http.javadsl.settings.ClientConnectionSettings;
import org.apache.pekko.http.javadsl.settings.ConnectionPoolSettings;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.OutgoingConnection;

import static org.apache.pekko.http.javadsl.ConnectHttp.toHost;
import static org.apache.pekko.util.ByteString.emptyByteString;
import org.apache.pekko.stream.javadsl.*;
import org.apache.pekko.util.ByteString;

import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletionStage;

import scala.concurrent.ExecutionContextExecutor;

import static org.apache.pekko.util.ByteString.emptyByteString;

// #manual-entity-consume-example-1
import java.io.File;

import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import scala.concurrent.duration.FiniteDuration;

import org.apache.pekko.stream.javadsl.Framing;
import org.apache.pekko.http.javadsl.model.*;
import scala.concurrent.duration.FiniteDuration;
// #manual-entity-consume-example-1

// #single-request-in-actor-example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.pekko.actor.typed.javadsl.ActorContext;
import org.apache.pekko.actor.typed.javadsl.Behaviors;
import org.apache.pekko.actor.typed.javadsl.Receive;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.ServerBinding;
import org.apache.pekko.http.javadsl.marshallers.jackson.Jackson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// #low-level-server-example
import org.apache.pekko.actor.typed.ActorSystem;
import org.apache.pekko.actor.typed.javadsl.Behaviors;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.ServerBinding;
import org.apache.pekko.http.javadsl.model.ContentTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.apache.pekko.NotUsed;
import org.apache.pekko.actor.typed.ActorSystem;
import org.apache.pekko.actor.typed.javadsl.Behaviors;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.ServerBinding;
import org.apache.pekko.http.javadsl.model.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package docs.http.javadsl;

import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.ConnectionContext;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.HttpsConnectionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.apache.pekko.NotUsed;
import org.apache.pekko.actor.typed.ActorSystem;
import org.apache.pekko.actor.typed.javadsl.Behaviors;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.ServerBinding;
import org.apache.pekko.http.javadsl.marshallers.jackson.Jackson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void bindingExample() throws Exception {
Materializer materializer = Materializer.createMaterializer(system);

Source<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 8080));
Http.get(system).newServerAt("localhost", 8080).connectionSource();

CompletionStage<ServerBinding> serverBindingFuture =
serverSource
Expand All @@ -73,7 +73,7 @@ public static void bindingFailureExample() throws Exception {
Materializer materializer = Materializer.createMaterializer(system);

Source<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 80));
Http.get(system).newServerAt("localhost", 80).connectionSource();

CompletionStage<ServerBinding> serverBindingFuture =
serverSource
Expand Down Expand Up @@ -101,7 +101,7 @@ public static void connectionSourceFailureExample() throws Exception {
Materializer materializer = Materializer.createMaterializer(system);

Source<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 8080));
Http.get(system).newServerAt("localhost", 8080).connectionSource();

Flow<IncomingConnection, IncomingConnection, NotUsed> failureDetection =
Flow.of(IncomingConnection.class)
Expand Down Expand Up @@ -137,7 +137,7 @@ public static void connectionStreamFailureExample() throws Exception {
Materializer materializer = Materializer.createMaterializer(system);

Source<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 8080));
Http.get(system).newServerAt("localhost", 8080).connectionSource();

Flow<HttpRequest, HttpRequest, NotUsed> failureDetection =
Flow.of(HttpRequest.class)
Expand Down Expand Up @@ -186,7 +186,7 @@ public static void fullServerExample() throws Exception {
final Materializer materializer = Materializer.createMaterializer(system);

Source<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectHttp.toHost("localhost", 8080));
Http.get(system).newServerAt("localhost", 8080).connectionSource();

// #request-handler
final Function<HttpRequest, HttpResponse> requestHandler =
Expand Down Expand Up @@ -379,10 +379,8 @@ public static void gracefulTerminationExample() throws Exception {

CompletionStage<ServerBinding> binding =
Http.get(system)
.bindAndHandle(
Directives.complete("Hello world!").flow(system, materializer),
ConnectHttp.toHost("localhost", 8080),
materializer);
.newServerAt("localhost", 8080)
.bindFlow(Directives.complete("Hello world!").flow(system, materializer));

ServerBinding serverBinding = binding.toCompletableFuture().get(3, TimeUnit.SECONDS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,13 @@
package docs.http.javadsl.server;

import org.apache.pekko.actor.typed.javadsl.Behaviors;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.Http;
import static org.apache.pekko.http.javadsl.server.Directives.*;
import org.apache.pekko.http.javadsl.server.Route;
import org.apache.pekko.stream.Materializer;

@SuppressWarnings("deprecation")
public class PekkoHttp1020MigrationExample {
public static void main(String[] args) {
{
// #old-binding
// only worked with classic actor system
org.apache.pekko.actor.ActorSystem system =
org.apache.pekko.actor.ActorSystem.create("TheSystem");
Materializer mat = Materializer.createMaterializer(system);
Route route = get(() -> complete("Hello World!"));
Http.get(system)
.bindAndHandle(route.flow(system), ConnectHttp.toHost("localhost", 8080), mat);
// #old-binding
}

{
// #new-binding
// works with classic or typed actor system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.apache.pekko.NotUsed;
import org.apache.pekko.http.impl.util.JavaMapping;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.ConnectionContext;
import org.apache.pekko.http.javadsl.model.StatusCodes;
import org.apache.pekko.http.javadsl.model.ws.WebSocketRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.event.LoggingAdapter;
import org.apache.pekko.event.NoLogging;
import org.apache.pekko.http.javadsl.ConnectHttp;
import org.apache.pekko.http.javadsl.Http;
import org.apache.pekko.http.javadsl.ServerBinding;
import org.apache.pekko.http.javadsl.model.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,10 @@ package docs.http.scaladsl.server
import org.apache.pekko.actor.typed.scaladsl.Behaviors
import org.apache.pekko.http.scaladsl.Http
import org.apache.pekko.http.scaladsl.server.Route
import scala.annotation.nowarn

@nowarn("msg=is deprecated")
class PekkoHttp1020MigrationSpec {
import org.apache.pekko.http.scaladsl.server.Directives._

{
// #old-binding
// only worked with classic actor system
implicit val system = org.apache.pekko.actor.ActorSystem("TheSystem")
val route: Route =
get {
complete("Hello world")
}
Http().bindAndHandle(route, "localhost", 8080)
// #old-binding
}

{
// #new-binding
// works with both classic and typed ActorSystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ProblemFilters.exclude[IncompatibleMethTypeProblem]("org.apache.pekko.http.impl.
ProblemFilters.exclude[IncompatibleMethTypeProblem]("org.apache.pekko.http.impl.engine.server.HttpServerBluePrint#TimeoutAccessImpl.updateHandler")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.ConnectionContext.https")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.ConnectionContext.sslConfig")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.bind")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.bindAndHandle")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.bindAndHandleAsync")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.bindAndHandleSync")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.Http.createServerHttpsContext")
Expand Down Expand Up @@ -66,6 +68,10 @@ ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scalad
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpsConnectionContext.getClientAuth")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpsConnectionContext.getSslParameters")
ProblemFilters.exclude[MissingTypesProblem]("org.apache.pekko.http.scaladsl.HttpExt")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bind")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bind$*")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandle")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandle$*")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandleSync")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandleSync$*")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.HttpExt.bindAndHandleAsync")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import pekko.Done

import javax.net.ssl.SSLEngine
import scala.annotation.nowarn

Check warning on line 53 in http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala

View workflow job for this annotation

GitHub Actions / validate-links

Unused import

Check warning on line 53 in http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala

View workflow job for this annotation

GitHub Actions / Compile and test (2.13, 17)

Unused import

Check warning on line 53 in http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala

View workflow job for this annotation

GitHub Actions / Compile and test (2.12, 17)

Unused import
import scala.collection.immutable
import scala.concurrent.Future
import scala.concurrent.duration.Duration
Expand Down Expand Up @@ -224,7 +224,7 @@
engine.setUseClientMode(false)
Http2AlpnSupport.enableForServer(engine, setChosenProtocol)
}
@nowarn("msg=deprecated") // TODO find an alternative way to do this
// TODO find an alternative way to do this
val tls = TLS(() => createEngine(), _ => Success(()), IgnoreComplete)

ProtocolSwitch(_ => getChosenProtocol(), http1, http2).join(
Expand All @@ -234,7 +234,7 @@
def outgoingConnection(host: String, port: Int, connectionContext: HttpsConnectionContext,
clientConnectionSettings: ClientConnectionSettings, log: LoggingAdapter)
: Flow[HttpRequest, HttpResponse, Future[OutgoingConnection]] = {
@nowarn("msg=deprecated") // TODO find an alternative way to do this
// TODO find an alternative way to do this
def createEngine(): SSLEngine = {
val engine = connectionContext.engineCreator(Some((host, port)))
engine.setUseClientMode(true)
Expand Down
Loading
Loading