View | Details | Raw Unified | Return to bug 58201
Collapse All | Expand All

(-)a/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java (-1 lines)
Lines 634-640 public class HTTPHC3Impl extends HTTPHCAbstractImpl { Link Here
634
                    if (! HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
634
                    if (! HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
635
                        String v = header.getValue();
635
                        String v = header.getValue();
636
                        if (HTTPConstants.HEADER_HOST.equalsIgnoreCase(n)) {
636
                        if (HTTPConstants.HEADER_HOST.equalsIgnoreCase(n)) {
637
                            v = v.replaceFirst(":\\d+$",""); // remove any port specification // $NON-NLS-1$ $NON-NLS-2$
638
                            method.getParams().setVirtualHost(v);
637
                            method.getParams().setVirtualHost(v);
639
                        } else {
638
                        } else {
640
                            method.addRequestHeader(n, v);
639
                            method.addRequestHeader(n, v);
(-)a/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (-2 / +23 lines)
Lines 882-888 public class HTTPHC4Impl extends HTTPHCAbstractImpl { Link Here
882
                    if (! HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
882
                    if (! HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
883
                        String v = header.getValue();
883
                        String v = header.getValue();
884
                        if (HTTPConstants.HEADER_HOST.equalsIgnoreCase(n)) {
884
                        if (HTTPConstants.HEADER_HOST.equalsIgnoreCase(n)) {
885
                            int port = url.getPort();
885
                            int port = getPortFromHostHeader(v, url.getPort());
886
                            v = v.replaceFirst(":\\d+$",""); // remove any port specification // $NON-NLS-1$ $NON-NLS-2$
886
                            v = v.replaceFirst(":\\d+$",""); // remove any port specification // $NON-NLS-1$ $NON-NLS-2$
887
                            if (port != -1) {
887
                            if (port != -1) {
888
                                if (port == url.getDefaultPort()) {
888
                                if (port == url.getDefaultPort()) {
Lines 903-908 public class HTTPHC4Impl extends HTTPHCAbstractImpl { Link Here
903
    }
903
    }
904
904
905
    /**
905
    /**
906
     * Get port from the value of the Host header, or return the given
907
     * defaultValue
908
     * 
909
     * @param hostHeaderValue
910
     *            value of the http Host header
911
     * @param defaultValue
912
     *            value to be used, when no port could be extracted from
913
     *            hostHeaderValue
914
     * @return integer representing the port for the host header
915
     */
916
    private int getPortFromHostHeader(String hostHeaderValue, int defaultValue) {
917
        String[] hostParts = hostHeaderValue.split(":");
918
        if (hostParts.length > 1) {
919
            String portString = hostParts[hostParts.length - 1];
920
            if (portString.matches("^\\d+$")) {
921
                return Integer.valueOf(portString);
922
            }
923
        }
924
        return defaultValue;
925
    }
926
927
    /**
906
     * Get all the request headers for the <code>HttpMethod</code>
928
     * Get all the request headers for the <code>HttpMethod</code>
907
     *
929
     *
908
     * @param method
930
     * @param method
909
- 

Return to bug 58201