Java Code Examples for org.apache.jmeter.protocol.http.util.HTTPConstants#DEFAULT_HTTP_PORT

The following examples show how to use org.apache.jmeter.protocol.http.util.HTTPConstants#DEFAULT_HTTP_PORT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebSocketAbstractSampler.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Get the port; apply the default for the protocol if necessary.
 *
 * @return the port number, with default applied if required.
 */
public int getPort() {
    final int port = getPortIfSpecified();
    if (port == UNSPECIFIED_PORT) {
        String prot = getProtocol();
        if (WSS_PROTOCOL.equalsIgnoreCase(prot)) {
            return HTTPConstants.DEFAULT_HTTPS_PORT;
        }
        if (!WS_PROTOCOL.equalsIgnoreCase(prot)) {
            log.warn("Unexpected protocol: " + prot);
        }
        return HTTPConstants.DEFAULT_HTTP_PORT;
    }
    return port;
}
 
Example 2
Source File: WebSocketSampler.java    From JMeter-WebSocketSampler with Apache License 2.0 5 votes vote down vote up
/**
 * Tell whether the default port for the specified protocol is used
 *
 * @return true if the default port number for the protocol is used, false
 * otherwise
 */
public boolean isProtocolDefaultPort() {
    final int port = Integer.parseInt(getServerPort());
    final String protocol = getProtocol();
    return ("ws".equalsIgnoreCase(protocol) && port == HTTPConstants.DEFAULT_HTTP_PORT)
            || ("wss".equalsIgnoreCase(protocol) && port == HTTPConstants.DEFAULT_HTTPS_PORT);
}
 
Example 3
Source File: WebSocketSampler.java    From JMeter-WebSocketSampler with Apache License 2.0 5 votes vote down vote up
/**
 * Tell whether the default port for the specified protocol is used
 *
 * @return true if the default port number for the protocol is used, false
 * otherwise
 */
public boolean isProtocolDefaultPort() {
    final int port = Integer.parseInt(getServerPort());
    final String protocol = getProtocol();
    return ("ws".equalsIgnoreCase(protocol) && port == HTTPConstants.DEFAULT_HTTP_PORT)
            || ("wss".equalsIgnoreCase(protocol) && port == HTTPConstants.DEFAULT_HTTPS_PORT);
}
 
Example 4
Source File: WebSocketSampler.java    From jmeter-websocket with Apache License 2.0 5 votes vote down vote up
public static int getDefaultPort(String protocol,int port){
    if (port==URL_UNSPECIFIED_PORT){
        return
                protocol.equalsIgnoreCase(HTTPConstants.PROTOCOL_HTTP)  ? HTTPConstants.DEFAULT_HTTP_PORT :
                        protocol.equalsIgnoreCase(HTTPConstants.PROTOCOL_HTTPS) ? HTTPConstants.DEFAULT_HTTPS_PORT :
                                port;
    }
    return port;
}
 
Example 5
Source File: WebSocketSampler.java    From jmeter-websocket with Apache License 2.0 5 votes vote down vote up
/**
 * Tell whether the default port for the specified protocol is used
 *
 * @return true if the default port number for the protocol is used, false otherwise
 */
public boolean isProtocolDefaultPort() {
    final int port = getPortIfSpecified();
    final String protocol = getProtocol();
    return port == UNSPECIFIED_PORT ||
            ("ws".equalsIgnoreCase(protocol) && port == HTTPConstants.DEFAULT_HTTP_PORT) ||
            ("wss".equalsIgnoreCase(protocol) && port == HTTPConstants.DEFAULT_HTTPS_PORT);
}
 
Example 6
Source File: WebSocketSampler.java    From jmeter-websocket with Apache License 2.0 5 votes vote down vote up
public int getPort() {
    final int port = getPortIfSpecified();
    if (port == UNSPECIFIED_PORT) {
        String prot = getProtocol();
        if ("wss".equalsIgnoreCase(prot)) {
            return HTTPConstants.DEFAULT_HTTPS_PORT;
        }
        if (!"ws".equalsIgnoreCase(prot)) {
            log.warn("Unexpected protocol: "+prot);
            // TODO - should this return something else?
        }
        return HTTPConstants.DEFAULT_HTTP_PORT;
    }
    return port;
}