当前位置: 首页>>代码示例>>Java>>正文


Java HttpMethodBase.setQueryString方法代码示例

本文整理汇总了Java中org.apache.commons.httpclient.HttpMethodBase.setQueryString方法的典型用法代码示例。如果您正苦于以下问题:Java HttpMethodBase.setQueryString方法的具体用法?Java HttpMethodBase.setQueryString怎么用?Java HttpMethodBase.setQueryString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.httpclient.HttpMethodBase的用法示例。


在下文中一共展示了HttpMethodBase.setQueryString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setQueryString

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
private HttpMethodBase setQueryString(HttpMethodBase method) {
    Map<String, List<String>> value = getNameValuePairs(query, "query");
    if (value != null) {
        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
        for (Map.Entry<String, List<String>> entry : value.entrySet()) {
            for (String v : entry.getValue()) {
                pairs.add(new NameValuePair(entry.getKey(), v));
            }
        }
        method.setQueryString(pairs.toArray(new NameValuePair[pairs.size()]));
    } else if (query != null) {
        method.setQueryString(query.toString());
    }
    return method;

}
 
开发者ID:niuxuetao,项目名称:paxml,代码行数:17,代码来源:HttpTag.java

示例2: getCSVDownload

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Makes a CSV download request and returns the resulting data in a CSVDownloadResponse
 *
 * Response should be a stream of bytes for a CSV file
 *
 * @param serviceUrl The URL of an observation and measurements URL (obtained from a getDatasetCollection response)
 * @param datasetId The dataset to download
 * @return
 * @throws Exception
 */
public CSVDownloadResponse getCSVDownload(String serviceUrl, String datasetId) throws Exception {

    //This is to workaround some erroneous behaviour from the dataservice
    //Where the logged omUrl points to a geoserver instance RATHER than the actual WFS service endpoint
    if (!serviceUrl.endsWith("wfs") && !serviceUrl.endsWith("wfs/")) {
    	log.warn("altering ServiceURL:" + serviceUrl);
    	
        if (serviceUrl.endsWith("/")) {
            serviceUrl += "wfs";
        } else {
            serviceUrl += "/wfs";
        }
        
        log.warn("altered ServiceURL:" + serviceUrl);
    }

    //We need to make a normal WFS request with some simple modifications
    HttpMethodBase method = wfsMethodMaker.makeGetMethod(serviceUrl, "om:GETPUBLISHEDSYSTEMTSA", (Integer)null, null);
    String newQueryString = method.getQueryString() + String.format("&CQL_FILTER=(DATASET_ID='%1$s')&outputformat=csv", datasetId);
    method.setQueryString(newQueryString);

    InputStream responseStream = httpServiceCaller.getMethodResponseAsStream(method);
    Header contentHeader = method.getResponseHeader("Content-Type");

    return new CSVDownloadResponse(responseStream, contentHeader == null ? null : contentHeader.getValue());
}
 
开发者ID:AuScope,项目名称:detcrc-portal,代码行数:37,代码来源:NVCLDataService.java

示例3: populateCommonProperties

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Method used to copy all the common properties
 *
 * @param msgContext       - The messageContext of the request message
 * @param url              - The target URL
 * @param httpMethod       - The http method used to send the request
 * @param httpClient       - The httpclient used to send the request
 * @param soapActionString - The soap action atring of the request message
 * @return MessageFormatter - The messageFormatter for the relavent request message
 * @throws AxisFault - Thrown in case an exception occurs
 */
protected MessageFormatter populateCommonProperties(MessageContext msgContext, URL url,
                                                  HttpMethodBase httpMethod,
                                                  HttpClient httpClient,
                                                  String soapActionString)
        throws AxisFault {

    if (isAuthenticationEnabled(msgContext)) {
        httpMethod.setDoAuthentication(true);
    }

    MessageFormatter messageFormatter = MessageProcessorSelector
                    .getMessageFormatter(msgContext);

    url = messageFormatter.getTargetAddress(msgContext, format, url);

    httpMethod.setPath(url.getPath());

    httpMethod.setQueryString(url.getQuery());

    // If adding the Content-Type header from the message formatter needs to be skipped
    if (Boolean.parseBoolean((String)msgContext.getProperty(HTTPConstants.NO_DEFAULT_CONTENT_TYPE))) {
        // Check whether message context already has the Content-Type header,
        // if so use that as the Content-Type header
        Object transportHeadersObj = msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
        if (transportHeadersObj != null && transportHeadersObj instanceof Map) {
            Map transportHeaders = (Map) transportHeadersObj;
            Object headerContentType = transportHeaders.get(HTTPConstants.HEADER_CONTENT_TYPE);
            if (headerContentType != null) {
                httpMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, headerContentType.toString());
            }
        }
        // If NO_DEFAULT_CONTENT_TYPE is set to true and the Content-Type header is not present
        // in the message context, backend will receive a request without a Content-Type header
    } else {
        httpMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
                messageFormatter.getContentType(msgContext, format, soapActionString));
    }

    httpMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());

    if (msgContext.getOptions() != null && msgContext.getOptions().isManageSession()) {
        // setting the cookie in the out path
        Object cookieString = msgContext.getProperty(HTTPConstants.COOKIE_STRING);

        if (cookieString != null) {
            StringBuffer buffer = new StringBuffer();
            buffer.append(cookieString);
            httpMethod.setRequestHeader(HTTPConstants.HEADER_COOKIE, buffer.toString());
        }
    }

    if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
        httpClient.getParams().setVersion(HttpVersion.HTTP_1_0);
    }
    return messageFormatter;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:68,代码来源:AbstractHTTPSender.java


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