@@ -231,8 +231,10 @@ private[spark] object JettyUtils extends Logging {
231231 ServerInfo (server, boundPort, collection)
232232 }
233233
234- // to generate a new url string scheme://server:port+path
235- private def newURL (scheme : String , server : String , port : Int , path : String , query : String ) = {
234+ // Create a new URI from the arguments, handling IPv6 host encoding and default ports. Based on:
235+ // https://github.com/eclipse/jetty.project/blob/master/jetty-util/src/main/java/org/eclipse/
236+ // jetty/util/URIUtil.java#L726-L733
237+ private def newURI (scheme : String , server : String , port : Int , path : String , query : String ) = {
236238 val builder = new StringBuilder
237239
238240 if (server.indexOf(':' ) >= 0 && server.charAt(0 ) != '[' ) {
@@ -258,11 +260,11 @@ private[spark] object JettyUtils extends Logging {
258260 if (baseRequest.isSecure) {
259261 return
260262 }
261- val httpsURL = newURL (scheme, baseRequest.getServerName, securePort,
263+ val httpsURI = newURI (scheme, baseRequest.getServerName, securePort,
262264 baseRequest.getRequestURI, baseRequest.getQueryString)
263265 response.setContentLength(0 )
264- response.encodeRedirectURL(httpsURL )
265- response.sendRedirect(httpsURL )
266+ response.encodeRedirectURL(httpsURI )
267+ response.sendRedirect(httpsURI )
266268 baseRequest.setHandled(true )
267269 }
268270 })
0 commit comments