Class HttpExt
- java.lang.Object
-
- akka.http.scaladsl.HttpExt
-
- All Implemented Interfaces:
akka.actor.Extension
public class HttpExt extends java.lang.Object implements akka.actor.Extension
Akka extension for HTTP which serves as the main entry point into akka-http.Use as
Http().bindAndHandle
etc. with an implicitActorSystem
in scope.
-
-
Constructor Summary
Constructors Constructor Description HttpExt(com.typesafe.config.Config config, akka.actor.ExtendedActorSystem system)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description akka.stream.scaladsl.Source<Http.IncomingConnection,scala.concurrent.Future<Http.ServerBinding>>
bind(java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log)
Deprecated.Use Http().newServerAt(...)...connectionSource() to create a source that can be materialized to a binding.scala.concurrent.Future<Http.ServerBinding>
bindAndHandle(akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,java.lang.Object> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Deprecated.Use Http().newServerAt(...)...bindFlow() to create server bindings.scala.concurrent.Future<Http.ServerBinding>
bindAndHandleAsync(scala.Function1<HttpRequest,scala.concurrent.Future<HttpResponse>> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, int parallelism, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Deprecated.Use Http().newServerAt(...)...bind() to create server bindings.scala.concurrent.Future<Http.ServerBinding>
bindAndHandleAsyncImpl(scala.Function1<HttpRequest,scala.concurrent.Future<HttpResponse>> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, int parallelism, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
scala.concurrent.Future<Http.ServerBinding>
bindAndHandleImpl(akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,java.lang.Object> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
scala.concurrent.Future<Http.ServerBinding>
bindAndHandleSync(scala.Function1<HttpRequest,HttpResponse> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Deprecated.Use Http().newServerAt(...)...bindSync() to create server bindings.akka.stream.scaladsl.Source<Http.IncomingConnection,scala.concurrent.Future<Http.ServerBinding>>
bindImpl(java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log)
<T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool>
cachedHostConnectionPool(java.lang.String host, int port, ConnectionPoolSettings settings, akka.event.LoggingAdapter log)
Returns aFlow
which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint.<T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool>
cachedHostConnectionPoolHttps(java.lang.String host, int port, HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, akka.event.LoggingAdapter log)
Same ascachedHostConnectionPool(java.lang.String, int, akka.http.scaladsl.settings.ConnectionPoolSettings, akka.event.LoggingAdapter)
but for encrypted (HTTPS) connections.akka.stream.scaladsl.BidiFlow<HttpRequest,akka.stream.TLSProtocol.SslTlsOutbound,akka.stream.TLSProtocol.SslTlsInbound,HttpResponse,akka.NotUsed>
clientLayer(Host hostHeader)
Constructs aakka.http.scaladsl.Http.ClientLayer
stage using the configured defaultClientConnectionSettings
, configured using theakka.http.client
config section.akka.stream.scaladsl.BidiFlow<HttpRequest,akka.stream.TLSProtocol.SslTlsOutbound,akka.stream.TLSProtocol.SslTlsInbound,HttpResponse,akka.NotUsed>
clientLayer(Host hostHeader, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Constructs aakka.http.scaladsl.Http.ClientLayer
stage using the givenClientConnectionSettings
.OutgoingConnectionBuilder
connectionTo(java.lang.String host)
Creates a builder which will create a single connection to a host every time the built flow is materialized.DateHeaderRendering
dateHeaderRendering()
HttpsConnectionContext
defaultClientHttpsContext()
Gets the current default client-sideHttpsConnectionContext
.ConnectionContext
defaultServerHttpContext()
Deprecated.Set context explicitly when binding.<T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool>
newHostConnectionPool(HostConnectionPoolSetup setup, akka.stream.Materializer fm)
INTERNAL API<T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool>
newHostConnectionPool(java.lang.String host, int port, ConnectionPoolSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Starts a new connection pool to the given host and configuration and returns aFlow
which dispatches the requests from all its materializations across this pool.<T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool>
newHostConnectionPoolHttps(java.lang.String host, int port, HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Same asnewHostConnectionPool(java.lang.String, int, akka.http.scaladsl.settings.ConnectionPoolSettings, akka.event.LoggingAdapter, akka.stream.Materializer)
but for encrypted (HTTPS) connections.ServerBuilder
newServerAt(java.lang.String interface_, int port)
Main entry point to create a server binding.akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,scala.concurrent.Future<Http.OutgoingConnection>>
outgoingConnection(java.lang.String host, int port, scala.Option<java.net.InetSocketAddress> localAddress, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Creates aFlow
representing a prospective HTTP client connection to the given endpoint.akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,scala.concurrent.Future<Http.OutgoingConnection>>
outgoingConnectionHttps(java.lang.String host, int port, HttpsConnectionContext connectionContext, scala.Option<java.net.InetSocketAddress> localAddress, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Same asoutgoingConnection(java.lang.String, int, scala.Option<java.net.InetSocketAddress>, akka.http.scaladsl.settings.ClientConnectionSettings, akka.event.LoggingAdapter)
but for encrypted (HTTPS) connections.akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,scala.concurrent.Future<Http.OutgoingConnection>>
outgoingConnectionUsingContext(java.lang.String host, int port, ConnectionContext connectionContext, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Similar tooutgoingConnection
but allows to specify a user-defined context to run the connection on.PoolMaster
poolMaster()
scala.concurrent.Future<java.lang.Object>
poolSize()
INTERNAL APIakka.stream.scaladsl.BidiFlow<HttpResponse,akka.stream.TLSProtocol.SslTlsOutbound,akka.stream.TLSProtocol.SslTlsInbound,HttpRequest,akka.NotUsed>
serverLayer(ServerSettings settings, scala.Option<java.net.InetSocketAddress> remoteAddress, akka.event.LoggingAdapter log, boolean isSecureConnection)
Constructs aakka.http.scaladsl.Http.ServerLayer
stage using the givenServerSettings
.void
setDefaultClientHttpsContext(HttpsConnectionContext context)
Sets the default client-sideHttpsConnectionContext
.void
setDefaultServerHttpContext(ConnectionContext context)
Deprecated.Set context explicitly when binding.scala.concurrent.Future<scala.runtime.BoxedUnit>
shutdownAllConnectionPools()
Triggers an orderly shutdown of all host connections pools currently maintained by theActorSystem
.scala.concurrent.Future<HttpResponse>
singleRequest(HttpRequest request, HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, akka.event.LoggingAdapter log)
Fires a singleHttpRequest
across the (cached) host connection pool for the request's effective URI to produce a response future.<T> scala.Tuple2<scala.concurrent.Future<WebSocketUpgradeResponse>,T>
singleWebSocketRequest(WebSocketRequest request, akka.stream.scaladsl.Flow<Message,Message,T> clientFlow, ConnectionContext connectionContext, scala.Option<java.net.InetSocketAddress> localAddress, ClientConnectionSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer mat)
Runs a single WebSocket conversation given a Uri and a flow that represents the client side of the WebSocket conversation.akka.stream.scaladsl.BidiFlow<akka.stream.TLSProtocol.SslTlsOutbound,akka.util.ByteString,akka.util.ByteString,akka.stream.TLSProtocol.SslTlsInbound,akka.NotUsed>
sslTlsClientStage(ConnectionContext connectionContext, java.lang.String host, int port)
Creates real or placebo SslTls stage based on if ConnectionContext is HTTPS or not.akka.stream.scaladsl.BidiFlow<akka.stream.TLSProtocol.SslTlsOutbound,akka.util.ByteString,akka.util.ByteString,akka.stream.TLSProtocol.SslTlsInbound,akka.NotUsed>
sslTlsServerStage(ConnectionContext connectionContext)
<T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,akka.NotUsed>
superPool(HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, akka.event.LoggingAdapter log)
Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs.akka.actor.ExtendedActorSystem
system()
akka.stream.scaladsl.Flow<Message,Message,scala.concurrent.Future<WebSocketUpgradeResponse>>
webSocketClientFlow(WebSocketRequest request, ConnectionContext connectionContext, scala.Option<java.net.InetSocketAddress> localAddress, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Constructs a flow that once materialized establishes a WebSocket connection to the given Uri.akka.stream.scaladsl.BidiFlow<Message,akka.stream.TLSProtocol.SslTlsOutbound,akka.stream.TLSProtocol.SslTlsInbound,Message,scala.concurrent.Future<WebSocketUpgradeResponse>>
webSocketClientLayer(WebSocketRequest request, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Constructs aakka.http.scaladsl.Http.WebSocketClientLayer
stage using the configured defaultClientConnectionSettings
, configured using theakka.http.client
config section.
-
-
-
Method Detail
-
bind
public akka.stream.scaladsl.Source<Http.IncomingConnection,scala.concurrent.Future<Http.ServerBinding>> bind(java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log)
Deprecated.Use Http().newServerAt(...)...connectionSource() to create a source that can be materialized to a binding. Since 10.2.0.Creates aSource
ofHttp.IncomingConnection
instances which represents a prospective HTTP server binding on the givenendpoint
.If the given port is 0 the resulting source can be materialized several times. Each materialization will then be assigned a new local port by the operating system, which can then be retrieved by the materialized
Http.ServerBinding
.If the given port is non-zero subsequent materialization attempts of the produced source will immediately fail, unless the first materialization has already been unbound. Unbinding can be triggered via the materialized
Http.ServerBinding
.If an
ConnectionContext
is given it will be used for setting up TLS encryption on the binding. Otherwise the binding will be unencrypted.If no
port
is explicitly given (or the port value is negative) the protocol's default port will be used, which is 80 for HTTP and 443 for HTTPS.To configure additional settings for a server started using this method, use the
akka.http.server
config section or pass in aServerSettings
explicitly.- Parameters:
interface_
- (undocumented)port
- (undocumented)connectionContext
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
bindAndHandle
public scala.concurrent.Future<Http.ServerBinding> bindAndHandle(akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,java.lang.Object> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Deprecated.Use Http().newServerAt(...)...bindFlow() to create server bindings. Since 10.2.0.Convenience method which starts a new HTTP server at the given endpoint and uses the givenhandler
Flow
for processing all incoming connections.The number of concurrently accepted connections can be configured by overriding the
akka.http.server.max-connections
setting. Please see the documentation in the reference.conf for more information about what kind of guarantees to expect.To configure additional settings for a server started using this method, use the
akka.http.server
config section or pass in aServerSettings
explicitly.- Parameters:
handler
- (undocumented)interface_
- (undocumented)port
- (undocumented)connectionContext
- (undocumented)settings
- (undocumented)log
- (undocumented)fm
- (undocumented)- Returns:
- (undocumented)
-
bindAndHandleAsync
public scala.concurrent.Future<Http.ServerBinding> bindAndHandleAsync(scala.Function1<HttpRequest,scala.concurrent.Future<HttpResponse>> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, int parallelism, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Deprecated.Use Http().newServerAt(...)...bind() to create server bindings. Since 10.2.0.Convenience method which starts a new HTTP server at the given endpoint and uses the givenhandler
Flow
for processing all incoming connections.The number of concurrently accepted connections can be configured by overriding the
akka.http.server.max-connections
setting. Please see the documentation in the reference.conf for more information about what kind of guarantees to expect.To configure additional settings for a server started using this method, use the
akka.http.server
config section or pass in aServerSettings
explicitly.Parameter
parallelism
specifies how many requests are attempted to be handled concurrently per connection. In HTTP/1 this makes only sense if HTTP pipelining is enabled (which is not recommended). The default value of0
means that the value is taken from theakka.http.server.pipelining-limit
setting from the configuration. In HTTP/2, the default value is taken fromakka.http.server.http2.max-concurrent-streams
.Any other value for
parallelism
overrides the setting.- Parameters:
handler
- (undocumented)interface_
- (undocumented)port
- (undocumented)connectionContext
- (undocumented)settings
- (undocumented)parallelism
- (undocumented)log
- (undocumented)fm
- (undocumented)- Returns:
- (undocumented)
-
bindAndHandleAsyncImpl
public scala.concurrent.Future<Http.ServerBinding> bindAndHandleAsyncImpl(scala.Function1<HttpRequest,scala.concurrent.Future<HttpResponse>> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, int parallelism, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
-
bindAndHandleImpl
public scala.concurrent.Future<Http.ServerBinding> bindAndHandleImpl(akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,java.lang.Object> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
-
bindAndHandleSync
public scala.concurrent.Future<Http.ServerBinding> bindAndHandleSync(scala.Function1<HttpRequest,HttpResponse> handler, java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Deprecated.Use Http().newServerAt(...)...bindSync() to create server bindings. Since 10.2.0.Convenience method which starts a new HTTP server at the given endpoint and uses the givenhandler
Flow
for processing all incoming connections.The number of concurrently accepted connections can be configured by overriding the
akka.http.server.max-connections
setting. Please see the documentation in the reference.conf for more information about what kind of guarantees to expect.To configure additional settings for a server started using this method, use the
akka.http.server
config section or pass in aServerSettings
explicitly.- Parameters:
handler
- (undocumented)interface_
- (undocumented)port
- (undocumented)connectionContext
- (undocumented)settings
- (undocumented)log
- (undocumented)fm
- (undocumented)- Returns:
- (undocumented)
-
bindImpl
public akka.stream.scaladsl.Source<Http.IncomingConnection,scala.concurrent.Future<Http.ServerBinding>> bindImpl(java.lang.String interface_, int port, ConnectionContext connectionContext, ServerSettings settings, akka.event.LoggingAdapter log)
-
cachedHostConnectionPool
public <T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool> cachedHostConnectionPool(java.lang.String host, int port, ConnectionPoolSettings settings, akka.event.LoggingAdapter log)
Returns aFlow
which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint. For every ActorSystem, target host and pool configuration a separate connection pool is maintained. The HTTP layer transparently manages idle shutdown and restarting of connections pools as configured. The returnedFlow
instances therefore remain valid throughout the lifetime of the application.The internal caching logic guarantees that there will never be more than a single pool running for the given target host endpoint and configuration (in this ActorSystem).
Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.To configure additional settings for the pool (and requests made using it), use the
akka.http.host-connection-pool
config section or pass in aConnectionPoolSettings
explicitly.- Parameters:
host
- (undocumented)port
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
cachedHostConnectionPoolHttps
public <T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool> cachedHostConnectionPoolHttps(java.lang.String host, int port, HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, akka.event.LoggingAdapter log)
Same ascachedHostConnectionPool(java.lang.String, int, akka.http.scaladsl.settings.ConnectionPoolSettings, akka.event.LoggingAdapter)
but for encrypted (HTTPS) connections.If an explicit
ConnectionContext
is given then it rather than the configured defaultConnectionContext
will be used for encryption on the connections.To configure additional settings for the pool (and requests made using it), use the
akka.http.host-connection-pool
config section or pass in aConnectionPoolSettings
explicitly.- Parameters:
host
- (undocumented)port
- (undocumented)connectionContext
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
clientLayer
public akka.stream.scaladsl.BidiFlow<HttpRequest,akka.stream.TLSProtocol.SslTlsOutbound,akka.stream.TLSProtocol.SslTlsInbound,HttpResponse,akka.NotUsed> clientLayer(Host hostHeader)
Constructs aakka.http.scaladsl.Http.ClientLayer
stage using the configured defaultClientConnectionSettings
, configured using theakka.http.client
config section.- Parameters:
hostHeader
- (undocumented)- Returns:
- (undocumented)
-
clientLayer
public akka.stream.scaladsl.BidiFlow<HttpRequest,akka.stream.TLSProtocol.SslTlsOutbound,akka.stream.TLSProtocol.SslTlsInbound,HttpResponse,akka.NotUsed> clientLayer(Host hostHeader, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Constructs aakka.http.scaladsl.Http.ClientLayer
stage using the givenClientConnectionSettings
.- Parameters:
hostHeader
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
connectionTo
public OutgoingConnectionBuilder connectionTo(java.lang.String host)
Creates a builder which will create a single connection to a host every time the built flow is materialized. There is no pooling and you are yourself responsible for lifecycle management of the connection. For a more convenient Request level API seesingleRequest()
- Parameters:
host
- (undocumented)- Returns:
- A builder to configure more specific setup for the connection and then build a
Flow[Request, Response, Future[OutgoingConnection}
.
-
dateHeaderRendering
public DateHeaderRendering dateHeaderRendering()
-
defaultClientHttpsContext
public HttpsConnectionContext defaultClientHttpsContext()
Gets the current default client-sideHttpsConnectionContext
. Defaults used here can be configured using ssl-config or the context can be replaced usingsetDefaultClientHttpsContext(akka.http.scaladsl.HttpsConnectionContext)
- Returns:
- (undocumented)
-
defaultServerHttpContext
public ConnectionContext defaultServerHttpContext()
Deprecated.Set context explicitly when binding. Since 10.2.0.Gets the current default server-sideConnectionContext
– defaults to plain HTTP. Can be modified usingsetDefaultServerHttpContext(akka.http.scaladsl.ConnectionContext)
, and will then apply for servers bound after that call has completed.- Returns:
- (undocumented)
-
newHostConnectionPool
public <T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool> newHostConnectionPool(java.lang.String host, int port, ConnectionPoolSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Starts a new connection pool to the given host and configuration and returns aFlow
which dispatches the requests from all its materializations across this pool. While the started host connection pool internally shuts itself down automatically after the configured idle timeout it will spin itself up again if more requests arrive from an existing or a new client flow materialization. The returned flow therefore remains usable for the full lifetime of the application.Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.To configure additional settings for the pool (and requests made using it), use the
akka.http.host-connection-pool
config section or pass in aConnectionPoolSettings
explicitly.- Parameters:
host
- (undocumented)port
- (undocumented)settings
- (undocumented)log
- (undocumented)fm
- (undocumented)- Returns:
- (undocumented)
-
newHostConnectionPool
public <T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool> newHostConnectionPool(HostConnectionPoolSetup setup, akka.stream.Materializer fm)
INTERNAL API- Parameters:
setup
- (undocumented)fm
- (undocumented)- Returns:
- (undocumented)
-
newHostConnectionPoolHttps
public <T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,Http.HostConnectionPool> newHostConnectionPoolHttps(java.lang.String host, int port, HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer fm)
Same asnewHostConnectionPool(java.lang.String, int, akka.http.scaladsl.settings.ConnectionPoolSettings, akka.event.LoggingAdapter, akka.stream.Materializer)
but for encrypted (HTTPS) connections.If an explicit
ConnectionContext
is given then it rather than the configured defaultConnectionContext
will be used for encryption on the connections.To configure additional settings for the pool (and requests made using it), use the
akka.http.host-connection-pool
config section or pass in aConnectionPoolSettings
explicitly.- Parameters:
host
- (undocumented)port
- (undocumented)connectionContext
- (undocumented)settings
- (undocumented)log
- (undocumented)fm
- (undocumented)- Returns:
- (undocumented)
-
newServerAt
public ServerBuilder newServerAt(java.lang.String interface_, int port)
Main entry point to create a server binding.- Parameters:
interface
- The interface to bind to.port
- The port to bind to or0
if the port should be automatically assigned.interface_
- (undocumented)- Returns:
- (undocumented)
-
outgoingConnection
public akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,scala.concurrent.Future<Http.OutgoingConnection>> outgoingConnection(java.lang.String host, int port, scala.Option<java.net.InetSocketAddress> localAddress, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Creates aFlow
representing a prospective HTTP client connection to the given endpoint. Every materialization of the produced flow will attempt to establish a new outgoing connection.To configure additional settings for requests made using this method, use the
akka.http.client
config section or pass in aClientConnectionSettings
explicitly.Prefer
connectionTo(java.lang.String)
over this method.- Parameters:
host
- (undocumented)port
- (undocumented)localAddress
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
outgoingConnectionHttps
public akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,scala.concurrent.Future<Http.OutgoingConnection>> outgoingConnectionHttps(java.lang.String host, int port, HttpsConnectionContext connectionContext, scala.Option<java.net.InetSocketAddress> localAddress, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Same asoutgoingConnection(java.lang.String, int, scala.Option<java.net.InetSocketAddress>, akka.http.scaladsl.settings.ClientConnectionSettings, akka.event.LoggingAdapter)
but for encrypted (HTTPS) connections.If an explicit
HttpsConnectionContext
is given then it rather than the configured defaultHttpsConnectionContext
will be used for encryption on the connection.To configure additional settings for requests made using this method, use the
akka.http.client
config section or pass in aClientConnectionSettings
explicitly.Prefer
connectionTo(java.lang.String)
over this method.- Parameters:
host
- (undocumented)port
- (undocumented)connectionContext
- (undocumented)localAddress
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
outgoingConnectionUsingContext
public akka.stream.scaladsl.Flow<HttpRequest,HttpResponse,scala.concurrent.Future<Http.OutgoingConnection>> outgoingConnectionUsingContext(java.lang.String host, int port, ConnectionContext connectionContext, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Similar tooutgoingConnection
but allows to specify a user-defined context to run the connection on.Depending on the kind of
ConnectionContext
the implementation will add TLS between the given transport and the HTTP implementationTo configure additional settings for requests made using this method, use the
akka.http.client
config section or pass in aClientConnectionSettings
explicitly.Prefer
connectionTo(java.lang.String)
over this method.- Parameters:
host
- (undocumented)port
- (undocumented)connectionContext
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
poolMaster
public PoolMaster poolMaster()
-
poolSize
public scala.concurrent.Future<java.lang.Object> poolSize()
INTERNAL APIFor testing only
- Returns:
- (undocumented)
-
serverLayer
public akka.stream.scaladsl.BidiFlow<HttpResponse,akka.stream.TLSProtocol.SslTlsOutbound,akka.stream.TLSProtocol.SslTlsInbound,HttpRequest,akka.NotUsed> serverLayer(ServerSettings settings, scala.Option<java.net.InetSocketAddress> remoteAddress, akka.event.LoggingAdapter log, boolean isSecureConnection)
Constructs aakka.http.scaladsl.Http.ServerLayer
stage using the givenServerSettings
. The returnedBidiFlow
isn't reusable and can only be materialized once. TheremoteAddress
, if provided, will be added as a header to eachHttpRequest
this layer produces if theakka.http.server.remote-address-header
configuration option is enabled.- Parameters:
settings
- (undocumented)remoteAddress
- (undocumented)log
- (undocumented)isSecureConnection
- (undocumented)- Returns:
- (undocumented)
-
setDefaultClientHttpsContext
public void setDefaultClientHttpsContext(HttpsConnectionContext context)
Sets the default client-sideHttpsConnectionContext
.- Parameters:
context
- (undocumented)
-
setDefaultServerHttpContext
public void setDefaultServerHttpContext(ConnectionContext context)
Deprecated.Set context explicitly when binding. Since 10.2.0.Sets the default server-sideConnectionContext
. If it is an instance ofHttpsConnectionContext
then the server will be bound using HTTPS.- Parameters:
context
- (undocumented)
-
shutdownAllConnectionPools
public scala.concurrent.Future<scala.runtime.BoxedUnit> shutdownAllConnectionPools()
Triggers an orderly shutdown of all host connections pools currently maintained by theActorSystem
. The returned future is completed when all pools that were live at the time of this method call have completed their shutdown process.If existing pool client flows are re-used or new ones materialized concurrently with or after this method call the respective connection pools will be restarted and not contribute to the returned future.
- Returns:
- (undocumented)
-
singleRequest
public scala.concurrent.Future<HttpResponse> singleRequest(HttpRequest request, HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, akka.event.LoggingAdapter log)
Fires a singleHttpRequest
across the (cached) host connection pool for the request's effective URI to produce a response future.If an explicit
ConnectionContext
is given then it rather than the configured defaultConnectionContext
will be used for setting up the HTTPS connection pool, if the request is targeted towards anhttps
endpoint.Note that the request must have an absolute URI, otherwise the future will be completed with an error.
- Parameters:
request
- (undocumented)connectionContext
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
singleWebSocketRequest
public <T> scala.Tuple2<scala.concurrent.Future<WebSocketUpgradeResponse>,T> singleWebSocketRequest(WebSocketRequest request, akka.stream.scaladsl.Flow<Message,Message,T> clientFlow, ConnectionContext connectionContext, scala.Option<java.net.InetSocketAddress> localAddress, ClientConnectionSettings settings, akka.event.LoggingAdapter log, akka.stream.Materializer mat)
Runs a single WebSocket conversation given a Uri and a flow that represents the client side of the WebSocket conversation.- Parameters:
request
- (undocumented)clientFlow
- (undocumented)connectionContext
- (undocumented)localAddress
- (undocumented)settings
- (undocumented)log
- (undocumented)mat
- (undocumented)- Returns:
- (undocumented)
-
sslTlsClientStage
public akka.stream.scaladsl.BidiFlow<akka.stream.TLSProtocol.SslTlsOutbound,akka.util.ByteString,akka.util.ByteString,akka.stream.TLSProtocol.SslTlsInbound,akka.NotUsed> sslTlsClientStage(ConnectionContext connectionContext, java.lang.String host, int port)
Creates real or placebo SslTls stage based on if ConnectionContext is HTTPS or not.
-
sslTlsServerStage
public akka.stream.scaladsl.BidiFlow<akka.stream.TLSProtocol.SslTlsOutbound,akka.util.ByteString,akka.util.ByteString,akka.stream.TLSProtocol.SslTlsInbound,akka.NotUsed> sslTlsServerStage(ConnectionContext connectionContext)
-
superPool
public <T> akka.stream.scaladsl.Flow<scala.Tuple2<HttpRequest,T>,scala.Tuple2<scala.util.Try<HttpResponse>,T>,akka.NotUsed> superPool(HttpsConnectionContext connectionContext, ConnectionPoolSettings settings, akka.event.LoggingAdapter log)
Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs. Note that incoming requests must have an absolute URI.If an explicit
ConnectionContext
is given then it rather than the configured defaultConnectionContext
will be used for setting up HTTPS connection pools, if required.Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type
T
from the application which is emitted together with the corresponding response.To configure additional settings for the pool (and requests made using it), use the
akka.http.host-connection-pool
config section or pass in aConnectionPoolSettings
explicitly.- Parameters:
connectionContext
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
system
public akka.actor.ExtendedActorSystem system()
-
webSocketClientFlow
public akka.stream.scaladsl.Flow<Message,Message,scala.concurrent.Future<WebSocketUpgradeResponse>> webSocketClientFlow(WebSocketRequest request, ConnectionContext connectionContext, scala.Option<java.net.InetSocketAddress> localAddress, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Constructs a flow that once materialized establishes a WebSocket connection to the given Uri.The layer is not reusable and must only be materialized once.
- Parameters:
request
- (undocumented)connectionContext
- (undocumented)localAddress
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
webSocketClientLayer
public akka.stream.scaladsl.BidiFlow<Message,akka.stream.TLSProtocol.SslTlsOutbound,akka.stream.TLSProtocol.SslTlsInbound,Message,scala.concurrent.Future<WebSocketUpgradeResponse>> webSocketClientLayer(WebSocketRequest request, ClientConnectionSettings settings, akka.event.LoggingAdapter log)
Constructs aakka.http.scaladsl.Http.WebSocketClientLayer
stage using the configured defaultClientConnectionSettings
, configured using theakka.http.client
config section.The layer is not reusable and must only be materialized once.
- Parameters:
request
- (undocumented)settings
- (undocumented)log
- (undocumented)- Returns:
- (undocumented)
-
-