Skip to content
This repository was archived by the owner on Jun 13, 2018. It is now read-only.
Open
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
12 changes: 6 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ name := "web-push"

organization := "com.zivver"

version := "0.2.1"
version := "0.2.4"

scalaVersion := "2.12.1"
scalaVersion := "2.12.6"

crossScalaVersions := Seq("2.11.8", "2.12.1")
crossScalaVersions := Seq("2.11.11", "2.12.6")

libraryDependencies ++= Seq(
"com.pauldijou" %% "jwt-core" % "0.10.0",
"org.apache.httpcomponents" % "fluent-hc" % "4.5.2",
"org.bouncycastle" % "bcprov-jdk15on" % "1.55"
"com.pauldijou" %% "jwt-core" % "1.0.0",
"org.apache.httpcomponents" % "fluent-hc" % "4.5.6",
"org.bouncycastle" % "bcprov-jdk15on" % "1.60"
)

publishTo := {
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.13
sbt.version = 1.2.3
18 changes: 16 additions & 2 deletions src/main/scala/com.zivver.webpush/PushService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import org.apache.http.HttpResponse
import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.ByteArrayEntity
import org.apache.http.impl.client.HttpClients
import org.apache.http.client.config.RequestConfig
import org.apache.http.impl.client.HttpClientBuilder
import org.apache.http.message.BasicHeader
import pdi.jwt.Jwt
import pdi.jwt.JwtAlgorithm.ES256
Expand All @@ -22,7 +23,20 @@ case class PushService(publicKey: ECPublicKey, privateKey: ECPrivateKey, subject

private val base64encoder = Base64.getUrlEncoder
private val defaultTtl: Int = 2419200
private val httpClient: HttpClient = HttpClients.createDefault
private lazy val httpClient: HttpClient = createHttpClient

/**
* Creates a sensible HttpClient with basic timeouts of 5 secs
* @return
*/
protected def createHttpClient: HttpClient = {
val timeout = 5
val config = RequestConfig.custom
.setConnectTimeout(timeout * 1000)
.setConnectionRequestTimeout(timeout * 1000)
.setSocketTimeout(timeout * 1000).build
HttpClientBuilder.create.setDefaultRequestConfig(config).build
}

/**
* Send a data free push notification.
Expand Down