• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HTTPConstants类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.jmeter.protocol.http.util.HTTPConstants的典型用法代码示例。如果您正苦于以下问题:Java HTTPConstants类的具体用法?Java HTTPConstants怎么用?Java HTTPConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HTTPConstants类属于org.apache.jmeter.protocol.http.util包,在下文中一共展示了HTTPConstants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getRequestHeader

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
public String getRequestHeader(org.apache.jmeter.protocol.http.control.HeaderManager headerManager) {
	String headerString = "";

	if (headerManager != null) {
		CollectionProperty headers = headerManager.getHeaders();
		if (headers != null) {
			for (JMeterProperty jMeterProperty : headers) {
				org.apache.jmeter.protocol.http.control.Header header = (org.apache.jmeter.protocol.http.control.Header) jMeterProperty
						.getObjectValue();
				String n = header.getName();
				if (!HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)) {
					String v = header.getValue();
					v = v.replaceFirst(":\\d+$", "");
					headerString = headerString + n + ": " + v + "\n";
				}
			}
		}
	}

	return headerString;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:22,代码来源:HlsSampler.java


示例2: setConnectionHeaders

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
protected void setConnectionHeaders(ClientUpgradeRequest request, HeaderManager headerManager, CacheManager cacheManager) {
    if (headerManager != null) {
        CollectionProperty headers = headerManager.getHeaders();
        if (headers != null) {
            for (JMeterProperty jMeterProperty : headers) {
                org.apache.jmeter.protocol.http.control.Header header
                = (org.apache.jmeter.protocol.http.control.Header)
                        jMeterProperty.getObjectValue();
                String n = header.getName();
                if (! HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(n)){
                    String v = header.getValue();
            		request.setHeader(n, v);
                }
            }
        }
    }
    if (cacheManager != null){
    }
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:20,代码来源:WebSocketAbstractSampler.java


示例3: setHeaders

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Check the cache, and if there is a match, set the headers:
 * <ul>
 * <li>If-Modified-Since</li>
 * <li>If-None-Match</li>
 * </ul>
 * Commons HttpClient version
 * @param url URL to look up in cache
 * @param method where to set the headers
 * @deprecated HC3.1 will be dropped in upcoming version
 */
@Deprecated
public void setHeaders(URL url, HttpMethod method) {
    CacheEntry entry = getCache().get(url.toString());
    if (log.isDebugEnabled()){
        log.debug(method.getName()+"(OACH) "+url.toString()+" "+entry);
    }
    if (entry != null){
        final String lastModified = entry.getLastModified();
        if (lastModified != null){
            method.setRequestHeader(HTTPConstants.IF_MODIFIED_SINCE, lastModified);
        }
        final String etag = entry.getEtag();
        if (etag != null){
            method.setRequestHeader(HTTPConstants.IF_NONE_MATCH, etag);
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:29,代码来源:CacheManager.java


示例4: addFormUrls

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
private void addFormUrls(Document html, HTTPSampleResult result, HTTPSamplerBase config, 
        List<HTTPSamplerBase> potentialLinks) {
    NodeList rootList = html.getChildNodes();
    List<HTTPSamplerBase> urls = new LinkedList<>();
    for (int x = 0; x < rootList.getLength(); x++) {
        urls.addAll(HtmlParsingUtils.createURLFromForm(rootList.item(x), result.getURL()));
    }
    for (HTTPSamplerBase newUrl : urls) {
        newUrl.setMethod(HTTPConstants.POST);
        if (log.isDebugEnabled()) {
            log.debug("Potential Form match: " + newUrl.toString());
        }
        if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
            log.debug("Matched!");
            potentialLinks.add(newUrl);
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:19,代码来源:AnchorModifier.java


示例5: getConnectionHeaders

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Get all the headers for the <code>HttpURLConnection</code> passed in
 *
 * @param conn
 *            <code>HttpUrlConnection</code> which represents the URL
 *            request
 * @return the headers as a string
 */
private String getConnectionHeaders(HttpURLConnection conn) {
    // Get all the request properties, which are the headers set on the connection
    StringBuilder hdrs = new StringBuilder(100);
    Map<String, List<String>> requestHeaders = conn.getRequestProperties();
    for(Map.Entry<String, List<String>> entry : requestHeaders.entrySet()) {
        String headerKey=entry.getKey();
        // Exclude the COOKIE header, since cookie is reported separately in the sample
        if(!HTTPConstants.HEADER_COOKIE.equalsIgnoreCase(headerKey)) {
            // value is a List of Strings
            for (String value : entry.getValue()){
                hdrs.append(headerKey);
                hdrs.append(": "); // $NON-NLS-1$
                hdrs.append(value);
                hdrs.append("\n"); // $NON-NLS-1$
            }
        }
    }
    return hdrs.toString();
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:28,代码来源:HTTPJavaImpl.java


示例6: setPostHeaders

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
protected int setPostHeaders(PostMethod post) {
    int length=0;// Take length from file
    if (getHeaderManager() != null) {
        // headerManager was set, so let's set the connection
        // to use it.
        HeaderManager mngr = getHeaderManager();
        int headerSize = mngr.size();
        for (int idx = 0; idx < headerSize; idx++) {
            Header hd = mngr.getHeader(idx);
            if (HTTPConstants.HEADER_CONTENT_LENGTH.equalsIgnoreCase(hd.getName())) {// Use this to override file length
                length = Integer.parseInt(hd.getValue());
                break;
            }
            // All the other headers are set up by HTTPSampler2.setupConnection()
        }
    } else {
        // otherwise we use "text/xml" as the default
        post.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, DEFAULT_CONTENT_TYPE); //$NON-NLS-1$
    }
    if (getSendSOAPAction()) {
        post.setRequestHeader(SOAPACTION, getSOAPActionQuoted());
    }
    return length;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:25,代码来源:SoapSampler.java


示例7: getConnectionHeaders

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Get all the request headers for the <code>HttpMethod</code>
 *
 * @param method
 *            <code>HttpMethod</code> which represents the request
 * @return the headers as a string
 */
private String getConnectionHeaders(HttpRequest method) {
    if(method != null) {
        // Get all the request headers
        StringBuilder hdrs = new StringBuilder(100);
        Header[] requestHeaders = method.getAllHeaders();
        for (Header requestHeader : requestHeaders) {
            // Exclude the COOKIE header, since cookie is reported separately in the sample
            if (!HTTPConstants.HEADER_COOKIE.equalsIgnoreCase(requestHeader.getName())) {
                writeResponseHeader(hdrs, requestHeader);
            }
        }

        return hdrs.toString();
    }
    return ""; ////$NON-NLS-1$
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:24,代码来源:HTTPHC4Impl.java


示例8: setPath

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Sets the PATH property; if the request is a GET or DELETE (and the path
 * does not start with http[s]://) it also calls {@link #parseArguments(String, String)}
 * to extract and store any query arguments.
 *
 * @param path
 *            The new Path value
 * @param contentEncoding
 *            The encoding used for the querystring parameter values
 */
public void setPath(String path, String contentEncoding) {
    boolean fullUrl = path.startsWith(HTTP_PREFIX) || path.startsWith(HTTPS_PREFIX);
    boolean getOrDelete = HTTPConstants.GET.equals(getMethod()) || HTTPConstants.DELETE.equals(getMethod());
    if (!fullUrl && getOrDelete) {
        int index = path.indexOf(QRY_PFX);
        if (index > -1) {
            setProperty(PATH, path.substring(0, index));
            // Parse the arguments in querystring, assuming specified encoding for values
            parseArguments(path.substring(index + 1), contentEncoding);
        } else {
            setProperty(PATH, path);
        }
    } else {
        setProperty(PATH, path);
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:27,代码来源:HTTPSamplerBase.java


示例9: getPort

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * 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 (HTTPConstants.PROTOCOL_HTTPS.equalsIgnoreCase(prot)) {
            return HTTPConstants.DEFAULT_HTTPS_PORT;
        }
        if (!HTTPConstants.PROTOCOL_HTTP.equalsIgnoreCase(prot)) {
            log.warn("Unexpected protocol: " + prot);
            // TODO - should this return something else?
        }
        return HTTPConstants.DEFAULT_HTTP_PORT;
    }
    return port;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:21,代码来源:HTTPSamplerBase.java


示例10: getConnectionHeaders

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Get all the request headers for the <code>HttpMethod</code>
 *
 * @param method
 *            <code>HttpMethod</code> which represents the request
 * @return the headers as a string
 */
protected String getConnectionHeaders(HttpMethod method) {
    // Get all the request headers
    StringBuilder hdrs = new StringBuilder(100);
    Header[] requestHeaders = method.getRequestHeaders();
    for (Header requestHeader : requestHeaders) {
        // Exclude the COOKIE header, since cookie is reported separately in the sample
        if (!HTTPConstants.HEADER_COOKIE.equalsIgnoreCase(requestHeader.getName())) {
            hdrs.append(requestHeader.getName());
            hdrs.append(": "); // $NON-NLS-1$
            hdrs.append(requestHeader.getValue());
            hdrs.append("\n"); // $NON-NLS-1$
        }
    }

    return hdrs.toString();
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:24,代码来源:HTTPHC3Impl.java


示例11: getServerPort

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
public String getServerPort() {
	final String port_s = getPropertyAsString("serverPort", "0");
	Integer port;
	String protocol = getProtocol();

	try {
		port = Integer.parseInt(port_s);
	} catch (Exception ex) {
		port = 0;
	}

	if (port == 0) {
		if ("wss".equalsIgnoreCase(protocol)) {
			return String.valueOf(HTTPConstants.DEFAULT_HTTPS_PORT);
		} else if ("ws".equalsIgnoreCase(protocol)) {
			return String.valueOf(HTTPConstants.DEFAULT_HTTP_PORT);
		}
	}
	return port.toString();
}
 
开发者ID:Fyro-Ing,项目名称:JMeter-WebSocket-StompSampler,代码行数:21,代码来源:WebSocketSampler.java


示例12: getServerPort

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
public String getServerPort() {
    final String port_s = getPropertyAsString("serverPort", "0");
    Integer port;
    String protocol = getProtocol();
    
    try {
        port = Integer.parseInt(port_s);
    } catch (Exception ex) {
        port = 0;
    }
    
    if (port == 0) {
        if ("wss".equalsIgnoreCase(protocol)) {
            return String.valueOf(HTTPConstants.DEFAULT_HTTPS_PORT);
        } else if ("ws".equalsIgnoreCase(protocol)) {
            return String.valueOf(HTTPConstants.DEFAULT_HTTP_PORT);
        }
    }
    return port.toString();
}
 
开发者ID:maciejzaleski,项目名称:JMeter-WebSocketSampler,代码行数:21,代码来源:WebSocketSampler.java


示例13: setHeaders

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Check the cache, and if there is a match, set the headers:<br/>
 * If-Modified-Since<br/>
 * If-None-Match<br/>
 * Commons HttpClient version
 * @param url URL to look up in cache
 * @param method where to set the headers
 */
public void setHeaders(URL url, HttpMethod method) {
    CacheEntry entry = getCache().get(url.toString());
    if (log.isDebugEnabled()){
        log.debug(method.getName()+"(OACH) "+url.toString()+" "+entry);
    }
    if (entry != null){
        final String lastModified = entry.getLastModified();
        if (lastModified != null){
            method.setRequestHeader(HTTPConstants.IF_MODIFIED_SINCE, lastModified);
        }
        final String etag = entry.getEtag();
        if (etag != null){
            method.setRequestHeader(HTTPConstants.IF_NONE_MATCH, etag);
        }
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:25,代码来源:CacheManager.java


示例14: modifyTestElement

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Modifies a given TestElement to mirror the data in the gui components.
 *
 * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
 */
@Override
public void modifyTestElement(TestElement s) {
    WebServiceSampler sampler = (WebServiceSampler) s;
    this.configureTestElement(sampler);
    sampler.setDomain(domain.getText());
    sampler.setProperty(HTTPSamplerBase.PORT,port.getText());
    sampler.setProtocol(protocol.getText());
    sampler.setPath(path.getText());
    sampler.setWsdlURL(wsdlField.getText());
    sampler.setMethod(HTTPConstants.POST);
    sampler.setSoapAction(soapAction.getText());
    sampler.setMaintainSession(maintainSession.isSelected());
    sampler.setXmlData(soapXml.getText());
    sampler.setXmlFile(soapXmlFile.getFilename());
    sampler.setXmlPathLoc(randomXmlFile.getText());
    sampler.setTimeout(connectTimeout.getText());
    sampler.setMemoryCache(memCache.isSelected());
    sampler.setReadResponse(readResponse.isSelected());
    sampler.setUseProxy(useProxy.isSelected());
    sampler.setProxyHost(proxyHost.getText());
    sampler.setProxyPort(proxyPort.getText());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:28,代码来源:WebServiceSamplerGui.java


示例15: addFormUrls

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
private void addFormUrls(Document html, HTTPSampleResult result, HTTPSamplerBase config, 
        List<HTTPSamplerBase> potentialLinks) {
    NodeList rootList = html.getChildNodes();
    List<HTTPSamplerBase> urls = new LinkedList<HTTPSamplerBase>();
    for (int x = 0; x < rootList.getLength(); x++) {
        urls.addAll(HtmlParsingUtils.createURLFromForm(rootList.item(x), result.getURL()));
    }
    for (HTTPSamplerBase newUrl : urls) {
        newUrl.setMethod(HTTPConstants.POST);
        if (log.isDebugEnabled()) {
            log.debug("Potential Form match: " + newUrl.toString());
        }
        if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
            log.debug("Matched!");
            potentialLinks.add(newUrl);
        }
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:19,代码来源:AnchorModifier.java


示例16: getProtocol

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * @param sampler {@link HTTPSamplerBase}
 * @return String Protocol (http or https)
 */
public String getProtocol(HTTPSamplerBase sampler) {
    if (url.indexOf("//") > -1) {
        String protocol = url.substring(0, url.indexOf(':'));
        if (log.isDebugEnabled()) {
            log.debug("Proxy: setting protocol to : " + protocol);
        }
        return protocol;
    } else if (sampler.getPort() == HTTPConstants.DEFAULT_HTTPS_PORT) {
        if (log.isDebugEnabled()) {
            log.debug("Proxy: setting protocol to https");
        }
        return HTTPS;
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Proxy setting default protocol to: http");
        }
        return HTTP;
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:24,代码来源:HttpRequestHdr.java


示例17: getConnectionHeaders

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Get all the request headers for the <code>HttpMethod</code>
 *
 * @param method
 *            <code>HttpMethod</code> which represents the request
 * @return the headers as a string
 */
private String getConnectionHeaders(HttpRequest method) {
    // Get all the request headers
    StringBuilder hdrs = new StringBuilder(100);
    Header[] requestHeaders = method.getAllHeaders();
    for(int i = 0; i < requestHeaders.length; i++) {
        // Exclude the COOKIE header, since cookie is reported separately in the sample
        if(!HTTPConstants.HEADER_COOKIE.equalsIgnoreCase(requestHeaders[i].getName())) {
            hdrs.append(requestHeaders[i].getName());
            hdrs.append(": "); // $NON-NLS-1$
            hdrs.append(requestHeaders[i].getValue());
            hdrs.append("\n"); // $NON-NLS-1$
        }
    }

    return hdrs.toString();
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:24,代码来源:HTTPHC4Impl.java


示例18: setPath

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Sets the PATH property; if the request is a GET or DELETE (and the path
 * does not start with http[s]://) it also calls {@link #parseArguments(String, String)}
 * to extract and store any query arguments.
 *
 * @param path
 *            The new Path value
 * @param contentEncoding
 *            The encoding used for the querystring parameter values
 */
public void setPath(String path, String contentEncoding) {
    boolean fullUrl = path.startsWith(HTTP_PREFIX) || path.startsWith(HTTPS_PREFIX); 
    if (!fullUrl && (HTTPConstants.GET.equals(getMethod()) || HTTPConstants.DELETE.equals(getMethod()))) {
        int index = path.indexOf(QRY_PFX);
        if (index > -1) {
            setProperty(PATH, path.substring(0, index));
            // Parse the arguments in querystring, assuming specified encoding for values
            parseArguments(path.substring(index + 1), contentEncoding);
        } else {
            setProperty(PATH, path);
        }
    } else {
        setProperty(PATH, path);
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:26,代码来源:HTTPSamplerBase.java


示例19: getPort

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * 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 (HTTPConstants.PROTOCOL_HTTPS.equalsIgnoreCase(prot)) {
            return HTTPConstants.DEFAULT_HTTPS_PORT;
        }
        if (!HTTPConstants.PROTOCOL_HTTP.equalsIgnoreCase(prot)) {
            log.warn("Unexpected protocol: "+prot);
            // TODO - should this return something else?
        }
        return HTTPConstants.DEFAULT_HTTP_PORT;
    }
    return port;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:21,代码来源:HTTPSamplerBase.java


示例20: getConnectionHeaders

import org.apache.jmeter.protocol.http.util.HTTPConstants; //导入依赖的package包/类
/**
 * Get all the request headers for the <code>HttpMethod</code>
 *
 * @param method
 *            <code>HttpMethod</code> which represents the request
 * @return the headers as a string
 */
protected String getConnectionHeaders(HttpMethod method) {
    // Get all the request headers
    StringBuilder hdrs = new StringBuilder(100);
    Header[] requestHeaders = method.getRequestHeaders();
    for(int i = 0; i < requestHeaders.length; i++) {
        // Exclude the COOKIE header, since cookie is reported separately in the sample
        if(!HTTPConstants.HEADER_COOKIE.equalsIgnoreCase(requestHeaders[i].getName())) {
            hdrs.append(requestHeaders[i].getName());
            hdrs.append(": "); // $NON-NLS-1$
            hdrs.append(requestHeaders[i].getValue());
            hdrs.append("\n"); // $NON-NLS-1$
        }
    }

    return hdrs.toString();
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:24,代码来源:HTTPHC3Impl.java



注:本文中的org.apache.jmeter.protocol.http.util.HTTPConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Component类代码示例发布时间:2022-05-23
下一篇:
Java ChartTheme类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap