Skip to content

Commit

Permalink
Merge branch '6.2.x' into 7.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetbehl committed Jan 26, 2024
2 parents 87cb7f7 + 8d30a96 commit d1cb568
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/groovy-joint-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,6 @@ jobs:
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
with:
arguments: |
arguments: |
build
-x groovydoc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ResponseRedirector {
if (absolute) {
redirectURI = processedActualUri.contains("://") ? processedActualUri : serverBaseURL + processedActualUri
} else {
redirectURI = processedActualUri
redirectURI = linkGenerator.contextPath + processedActualUri
}

String redirectUrl = useJessionId ? response.encodeRedirectURL(redirectURI) : redirectURI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ import spock.lang.Specification
*/
abstract class AbstractUrlMappingsSpec extends Specification{

static final String CONTEXT_PATH = 'app-context'

def setup() {
WebUtils.clearGrailsWebRequest()
}

LinkGenerator getLinkGeneratorWithContextPath(Closure mappings) {
LinkGeneratorFactory linkGeneratorFactory = new LinkGeneratorFactory()
linkGeneratorFactory.contextPath = CONTEXT_PATH
linkGeneratorFactory.create(mappings)
}
LinkGenerator getLinkGenerator(Closure mappings) {
new LinkGeneratorFactory().create(mappings)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,25 @@ class RedirectNonAbsoluteURISpec extends AbstractUrlMappingsSpec {
cleanup:
RequestContextHolder.setRequestAttributes(null)
}

@Issue('11673')
void 'An "absolute=false" redirect includes context-path in Location header'() {
given:
def linkGenerator = getLinkGeneratorWithContextPath {
"/$controller/$action?/$id?"()
}
def responseRedirector = new ResponseRedirector(linkGenerator)
HttpServletRequest request = Mock(HttpServletRequest) { lookup() >> GrailsWebMockUtil.bindMockWebRequest() }
HttpServletResponse response = Mock(HttpServletResponse)

when: 'redirecting with absolute=false where context-path is set'
responseRedirector.redirect(request, response, [controller: 'test', action: 'foo', absolute: false])

then: 'the partial URI includes context-path'
1 * response.setStatus(302)
1 * response.setHeader(HttpHeaders.LOCATION, CONTEXT_PATH + '/test/foo')

cleanup:
RequestContextHolder.setRequestAttributes(null)
}
}

0 comments on commit d1cb568

Please sign in to comment.