/[classpath]/inetlib/source/gnu/inet/http/HTTPURLConnection.java
ViewVC logotype

Diff of /inetlib/source/gnu/inet/http/HTTPURLConnection.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by dog, Wed Apr 27 18:19:02 2005 UTC revision 1.14 by dog, Sat May 28 13:30:37 2005 UTC
# Line 211  public class HTTPURLConnection Line 211  public class HTTPURLConnection
211            {            {
212              // Follow redirect              // Follow redirect
213              String location = response.getHeader("Location");              String location = response.getHeader("Location");
214              String connectionUri = connection.getURI();              if (location != null)
             int start = connectionUri.length();  
             if (location.startsWith(connectionUri) &&  
                 location.charAt(start) == '/')  
215                {                {
216                  file = location.substring(start);                  String connectionUri = connection.getURI();
217                  retry = true;                  int start = connectionUri.length();
218                }                  if (location.startsWith(connectionUri) &&
219              else if (location.startsWith("http:"))                      location.charAt(start) == '/')
220                {                    {
221                  connection.close();                      file = location.substring(start);
222                  connection = null;                      retry = true;
223                  secure = false;                    }
224                  start = 7;                  else if (location.startsWith("http:"))
225                  int end = location.indexOf('/', start);                    {
226                  host = location.substring(start, end);                      connection.close();
227                  int ci = host.lastIndexOf(':');                      connection = null;
228                  if (ci != -1)                      secure = false;
229                    {                      start = 7;
230                      port = Integer.parseInt(host.substring (ci + 1));                      int end = location.indexOf('/', start);
231                      host = host.substring(0, ci);                      host = location.substring(start, end);
232                    }                      int ci = host.lastIndexOf(':');
233                  else                      if (ci != -1)
234                    {                        {
235                      port = HTTPConnection.HTTP_PORT;                          port = Integer.parseInt(host.substring (ci + 1));
236                    }                          host = host.substring(0, ci);
237                  file = location.substring(end);                        }
238                  retry = true;                      else
239                }                        {
240              else if (location.startsWith("https:"))                          port = HTTPConnection.HTTP_PORT;
241                {                        }
242                  connection.close();                      file = location.substring(end);
243                  connection = null;                      retry = true;
244                  secure = true;                    }
245                  start = 8;                  else if (location.startsWith("https:"))
246                  int end = location.indexOf('/', start);                    {
247                  host = location.substring(start, end);                      connection.close();
248                  int ci = host.lastIndexOf(':');                      connection = null;
249                  if (ci != -1)                      secure = true;
250                    {                      start = 8;
251                      port = Integer.parseInt(host.substring (ci + 1));                      int end = location.indexOf('/', start);
252                      host = host.substring(0, ci);                      host = location.substring(start, end);
253                    }                      int ci = host.lastIndexOf(':');
254                  else                      if (ci != -1)
255                    {                        {
256                      port = HTTPConnection.HTTPS_PORT;                          port = Integer.parseInt(host.substring (ci + 1));
257                    }                          host = host.substring(0, ci);
258                  file = location.substring(end);                        }
259                  retry = true;                      else
260                }                        {
261              else if (location.length() > 0)                          port = HTTPConnection.HTTPS_PORT;
262                {                        }
263                  // Malformed absolute URI, treat as file part of URI                      file = location.substring(end);
264                  if (location.charAt(0) == '/')                      retry = true;
265                    {                    }
266                      // Absolute path                  else if (location.length() > 0)
267                      file = location;                    {
268                    }                      // Malformed absolute URI, treat as file part of URI
269                  else                      if (location.charAt(0) == '/')
270                    {                        {
271                      // Relative path                          // Absolute path
272                      int lsi = file.lastIndexOf('/');                          file = location;
273                      file = (lsi == -1) ? "/" : file.substring(0, lsi + 1);                        }
274                      file += location;                      else
275                          {
276                            // Relative path
277                            int lsi = file.lastIndexOf('/');
278                            file = (lsi == -1) ? "/" : file.substring(0, lsi + 1);
279                            file += location;
280                          }
281                        retry = true;
282                    }                    }
                 retry = true;  
283                }                }
284            }            }
285          else          else

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26