586 usingProxy = false;
587 return;
588 }
589 }
590 }
591
592 public String getURLFile() throws IOException {
593
594 String fileName;
595
596 /**
597 * proxyDisabled is set by subclass HttpsClient!
598 */
599 if (usingProxy && !proxyDisabled) {
600 // Do not use URLStreamHandler.toExternalForm as the fragment
601 // should not be part of the RequestURI. It should be an
602 // absolute URI which does not have a fragment part.
603 StringBuilder result = new StringBuilder(128);
604 result.append(url.getProtocol());
605 result.append(":");
606 if (url.getAuthority() != null && url.getAuthority().length() > 0) {
607 result.append("//");
608 result.append(url.getAuthority());
609 }
610 if (url.getPath() != null) {
611 result.append(url.getPath());
612 }
613 if (url.getQuery() != null) {
614 result.append('?');
615 result.append(url.getQuery());
616 }
617
618 fileName = result.toString();
619 } else {
620 fileName = url.getFile();
621
622 if ((fileName == null) || (fileName.length() == 0)) {
623 fileName = "/";
624 } else if (fileName.charAt(0) == '?') {
625 /* HTTP/1.1 spec says in 5.1.2. about Request-URI:
626 * "Note that the absolute path cannot be empty; if
627 * none is present in the original URI, it MUST be
628 * given as "/" (the server root)." So if the file
629 * name here has only a query string, the path is
630 * empty and we also have to add a "/".
631 */
632 fileName = "/" + fileName;
633 }
634 }
635
636 if (fileName.indexOf('\n') == -1)
637 return fileName;
638 else
639 throw new java.net.MalformedURLException("Illegal character in URL");
640 }
641
642 /**
|
586 usingProxy = false;
587 return;
588 }
589 }
590 }
591
592 public String getURLFile() throws IOException {
593
594 String fileName;
595
596 /**
597 * proxyDisabled is set by subclass HttpsClient!
598 */
599 if (usingProxy && !proxyDisabled) {
600 // Do not use URLStreamHandler.toExternalForm as the fragment
601 // should not be part of the RequestURI. It should be an
602 // absolute URI which does not have a fragment part.
603 StringBuilder result = new StringBuilder(128);
604 result.append(url.getProtocol());
605 result.append(":");
606 if (url.getAuthority() != null && !url.getAuthority().isEmpty()) {
607 result.append("//");
608 result.append(url.getAuthority());
609 }
610 if (url.getPath() != null) {
611 result.append(url.getPath());
612 }
613 if (url.getQuery() != null) {
614 result.append('?');
615 result.append(url.getQuery());
616 }
617
618 fileName = result.toString();
619 } else {
620 fileName = url.getFile();
621
622 if ((fileName == null) || (fileName.isEmpty())) {
623 fileName = "/";
624 } else if (fileName.charAt(0) == '?') {
625 /* HTTP/1.1 spec says in 5.1.2. about Request-URI:
626 * "Note that the absolute path cannot be empty; if
627 * none is present in the original URI, it MUST be
628 * given as "/" (the server root)." So if the file
629 * name here has only a query string, the path is
630 * empty and we also have to add a "/".
631 */
632 fileName = "/" + fileName;
633 }
634 }
635
636 if (fileName.indexOf('\n') == -1)
637 return fileName;
638 else
639 throw new java.net.MalformedURLException("Illegal character in URL");
640 }
641
642 /**
|