This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
! can, http: Add SSLSessionInfo header to requests on server and resp…
…onses on client
- Loading branch information
Showing
7 changed files
with
160 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
spray-can/src/main/scala/spray/can/parsing/SSLSessionInfoSupport.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2011-2013 spray.io | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package spray.can | ||
package parsing | ||
|
||
import spray.can.server.RequestParsing | ||
import spray.io._ | ||
import spray.http.HttpMessageStart | ||
import spray.http.HttpHeaders.`SSL-Session-Info` | ||
import spray.util.SSLSessionInfo | ||
|
||
/** Pipeline stage that adds the `SSL-Session-Info` header to incoming HTTP messages. */ | ||
object SSLSessionInfoSupport extends PipelineStage { | ||
|
||
def apply(context: PipelineContext, commandPL: CPL, eventPL: EPL): Pipelines = | ||
new Pipelines { | ||
var sslSessionInfo: Option[`SSL-Session-Info`] = None | ||
|
||
def addSessionInfoHeader(message: HttpMessageStart): HttpMessageStart = | ||
sslSessionInfo.fold(message) { info ⇒ message.mapHeaders { hdrs ⇒ info :: hdrs } } | ||
|
||
val commandPipeline: CPL = commandPL | ||
|
||
val eventPipeline: EPL = { | ||
case SslTlsSupport.SSLSessionEstablished(info) ⇒ | ||
sslSessionInfo = Some(`SSL-Session-Info`(info)) | ||
|
||
case Http.MessageEvent(msg: HttpMessageStart) if sslSessionInfo.isDefined ⇒ | ||
eventPL(Http.MessageEvent(addSessionInfoHeader(msg))) | ||
|
||
case RequestParsing.HttpMessageStartEvent(part, closeAfterResponseCompletion) if sslSessionInfo.isDefined ⇒ | ||
eventPL(RequestParsing.HttpMessageStartEvent(addSessionInfoHeader(part), closeAfterResponseCompletion)) | ||
|
||
case ev ⇒ eventPL(ev) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters