fix: java.net.URLConnection not following redirects from http to https
This commit is contained in:
		
							parent
							
								
									df3af8fab1
								
							
						
					
					
						commit
						8edc9db372
					
				
					 1 changed files with 22 additions and 12 deletions
				
			
		|  | @ -57,6 +57,8 @@ helma.Http = function() { | ||||||
|         "socket": 0 |         "socket": 0 | ||||||
|     }; |     }; | ||||||
|     var maxResponseSize = null; |     var maxResponseSize = null; | ||||||
|  |     var maxTries = 5; | ||||||
|  |     var currentTries = 0; | ||||||
| 
 | 
 | ||||||
|     var responseHandler = function(connection, result) { |     var responseHandler = function(connection, result) { | ||||||
|        var input; |        var input; | ||||||
|  | @ -556,6 +558,14 @@ helma.Http = function() { | ||||||
|             content: null, |             content: null, | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         // java.net.URLConnection does not follow redirects from http to https
 | ||||||
|  |         // See https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4620571
 | ||||||
|  |         if (followRedirects && [301, 303].contains(result.code) && result.location) { | ||||||
|  |           currentTries += 1; | ||||||
|  |           if (currentTries >= maxTries) throw new Error('Too many redirects'); | ||||||
|  |           return this.getUrl(result.location, opt); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         // parse all "Set-Cookie" header fields into an array of
 |         // parse all "Set-Cookie" header fields into an array of
 | ||||||
|         // helma.Http.Cookie instances
 |         // helma.Http.Cookie instances
 | ||||||
|         var setCookies = conn.getHeaderFields().get("Set-Cookie"); |         var setCookies = conn.getHeaderFields().get("Set-Cookie"); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue