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

Akka-HTTP backend #208

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
843a076
A prototype of Akka Http backend
2m Dec 11, 2017
c3a19f1
Cleanup integration tests
2m Dec 11, 2017
90a0903
Implement request filters
2m Dec 11, 2017
4e14d8a
Add missing type annotations
2m Dec 11, 2017
fb866dc
Add test cases from Java api integration tests
2m Dec 12, 2017
93adff4
All http methods
2m Dec 13, 2017
0f1a115
Authentication support
2m Dec 13, 2017
d044a86
Virtualhost support
2m Dec 13, 2017
ef39d98
Request timeout support
2m Dec 13, 2017
0b4ff08
First part of the Java API implementation
2m Dec 14, 2017
726039f
Ported all scala integration tests over java implementation
2m Dec 14, 2017
fe481c9
Java API implementation using javadsl Akka Http API
2m Dec 15, 2017
c5b3bd7
Port RequestFilter spec to Java backends
2m Dec 18, 2017
7315488
Refactor Scala API RequestFilter tests
2m Dec 18, 2017
8065f62
Add missing copyright headers
2m Dec 18, 2017
d26cb84
Implement
2m Dec 18, 2017
57f33b7
Mark unimplemented features as FIXMEs
2m Dec 18, 2017
cdc2704
Implement get status text
2m Dec 18, 2017
2f80e22
Save strict response if response is unmarshalled
2m Dec 18, 2017
13dbf85
Fix dependencies
2m Dec 18, 2017
5b4c495
Use Http Method name constants
2m Dec 18, 2017
13dc162
Fix race condition in test setup
2m Dec 19, 2017
036fd4b
Remove api converters from a failed previous attempt
2m Dec 19, 2017
e0a88ae
Fix Scala 2.11 compilation
2m Dec 19, 2017
875ad53
Implement cookies
2m Dec 19, 2017
4d6d517
Complete request timeout support
2m Dec 19, 2017
c10f727
Complete virtual host support
2m Dec 19, 2017
082b787
Implement auth getters
2m Dec 20, 2017
e03db58
Implement getters for url, method, content type and body
2m Dec 20, 2017
62de06d
Fix content type spec
2m Dec 20, 2017
bc19089
Typo fix
2m Dec 20, 2017
311bd62
Implement content type getter on response
2m Dec 20, 2017
0f16eac
Port AHC unit tests as integration tests for all APIs and backends
2m Dec 20, 2017
9c81700
Remove unnecessary dependency
2m Dec 20, 2017
d248fa4
Remove unused imports
2m Dec 20, 2017
526042c
Https tests and context parameter
2m Dec 22, 2017
766ae0b
Disable AHC HTTPS test while AHC backend is not configured
2m Dec 22, 2017
9ce489b
Formatting changes after rebase
2m Jan 23, 2018
58323ad
Remove deprecated formatting settings after rebase
2m Jan 23, 2018
814d633
Provide custom dns records via akka dns resolver
2m Jan 23, 2018
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
@@ -0,0 +1,15 @@
package akka.io
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to have this inside akka.io package instead of play.api.ws?


import java.net.InetAddress

import scala.concurrent.duration._

class AkkaExampleOrgToLocalhostDnsProvider extends DnsProvider {
override def cache: Dns = {
val cache = new SimpleDnsCache()
cache.put(Dns.Resolved("akka.example.org", Seq(InetAddress.getByName("127.0.0.1"))), 1.hour.toMillis)
cache
}
override def actorClass = classOf[InetAddressDnsResolver]
override def managerClass = classOf[SimpleDnsManager]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good :)

29 changes: 6 additions & 23 deletions integration-tests/src/test/scala/play/AkkaServerProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import akka.actor.ActorSystem
import akka.http.scaladsl.{ Http, HttpsConnectionContext }
import akka.http.scaladsl.server.Route
import akka.stream.ActorMaterializer
import com.typesafe.config.ConfigFactory
import org.specs2.concurrent.ExecutionEnv
import org.specs2.specification.BeforeAfterAll
import sun.net.spi.nameservice.NameService

import scala.concurrent.duration._
import scala.concurrent.{ Await, Future }
Expand All @@ -37,14 +37,15 @@ trait AkkaServerProvider extends BeforeAfterAll {
val defaultTimeout: FiniteDuration = 5.seconds

// Create Akka system for thread and streaming management
implicit val system = ActorSystem()
implicit val system = ActorSystem("AkkaServerProvider", ConfigFactory.parseString(
s"""
|akka.io.dns.inet-address.provider-object = ${classOf[akka.io.AkkaExampleOrgToLocalhostDnsProvider].getName}
""".stripMargin).withFallback(ConfigFactory.load()))
implicit val materializer = ActorMaterializer()

lazy val futureServer: Future[Seq[Http.ServerBinding]] = {
implicit val ec = executionEnv.executionContext

customNameserver()

// Using 0 (zero) means that a random free port will be used.
// So our tests can run in parallel and won't mess with each other.
val httpBinding = Http().bindAndHandle(routes, "localhost", 0)
Expand Down Expand Up @@ -107,22 +108,4 @@ trait AkkaServerProvider extends BeforeAfterAll {

private def loadX509Certificate(resourceName: String) =
CertificateFactory.getInstance("X.509").generateCertificate(resourceStream(resourceName))

class MyHostNameService extends NameService {
override def lookupAllHostAddr(hostname: String) =
if (hostname == "akka.example.org") {
val arrayOfByte = sun.net.util.IPAddressUtil.textToNumericFormatV4("127.0.0.1")
val address = InetAddress.getByAddress(hostname, arrayOfByte)
Array[InetAddress](address)
} else throw new UnknownHostException(hostname);

override def getHostByAddr(paramArrayOfByte: Array[Byte]) = throw new UnknownHostException(paramArrayOfByte.toString)
}

private def customNameserver() = {
val field = classOf[InetAddress].getDeclaredField("nameServices")
field.setAccessible(true)
val nameServices = field.get(null).asInstanceOf[java.util.List[sun.net.spi.nameservice.NameService]]
nameServices.add(new MyHostNameService)
}
}
}