-
Notifications
You must be signed in to change notification settings - Fork 276
Save the server-port of the original request #1865
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
Changes from 5 commits
c1ae4c7
4690d9b
24ecc46
d02d5ec
dbf0a52
6e1822e
875a787
487628d
2af50bb
5865ef9
9d63cad
17cc1d8
46bb3a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Copyright 2010-2011 WorldWide Conferencing, LLC | ||
| * | ||
| * 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 net.liftweb.http.provider.servlet | ||
|
|
||
| import net.liftweb.http.provider._ | ||
| import net.liftweb.mockweb.WebSpec | ||
| import org.mockito.Mockito._ | ||
| import org.specs2.mock.Mockito | ||
|
|
||
|
|
||
| object OfflineRequestSnapshotSpec extends WebSpec with Mockito { | ||
|
|
||
| "A snapshot request should" in { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Absolutely. I just wrote this up as a quick-n-dirty example to show the current implementation didn't work correctly. To be improved if approved. I guess this means I should go ahead and do the cleanup. |
||
| val mockHttpRequest = mock[HTTPRequest] | ||
| val mockProvider = mock[HTTPProvider] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could probably just be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting the Setting
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, right you are! It's not “right” in the sense that if this were live code it would be a bad idea. Since this is a test, I usually care a lot less. Think of it this way: with the mock, if someone tried to call something on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that you said it, |
||
| val headers = HTTPParam("X-SSL", List("true")) :: Nil | ||
| when(mockHttpRequest.headers).thenReturn(headers) | ||
| when(mockHttpRequest.cookies).thenReturn(Nil) | ||
| when(mockHttpRequest.params).thenReturn(Nil) | ||
| when(mockHttpRequest.serverPort).thenReturn(80) | ||
| val snapshotReq = new OfflineRequestSnapshot(mockHttpRequest, mockProvider) | ||
|
|
||
| "have a headers method that returns the list of headers with a given name" in { | ||
| snapshotReq.headers("X-SSL") shouldEqual List("true") | ||
|
|
||
| // this test shouldn't be successful | ||
| snapshotReq.headers("X-SSL") shouldEqual List("X-SSL") | ||
| } | ||
|
|
||
| "the new headers implementation should work correctly" in { | ||
| snapshotReq._newheaders("X-SSL") shouldEqual List("true") | ||
| } | ||
|
|
||
| "return server-port 443 when the X-SSL header is present" in { | ||
| snapshotReq.serverPort shouldEqual 443 | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're making this
private[servlet], I wonder if we just move it outside ofHTTPRequestServletand into its own file altogether? Not necessarily a pre-req for merging, just occurred to me while reading.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea.