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


Java HttpMethodBase.getResponseHeader方法代码示例

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


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

示例1: saveHeader

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Save a header from the given HTTP operation into the 
 * provider headers under a new name
 * 
 * @param origName header name to get if present
 * @param method http operation containing headers
 */
protected void saveHeader(String origName, HttpMethodBase method, 
        ANVLRecord headers, String newName) {
    Header header = method.getResponseHeader(origName);
    if(header!=null) {
        headers.addLabelValue(newName, header.getValue());
    }
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:15,代码来源:WARCWriterProcessor.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: getResponseAsStringAndHandleGzip

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
public static String getResponseAsStringAndHandleGzip(HttpMethodBase httpget) throws IOException {
    Header contentEncodingHeader = httpget.getResponseHeader(CONTENT_ENCODING_HEADER);
    InputStream stream = httpget.getResponseBodyAsStream();
    if (contentEncodingHeader != null && contentEncodingHeader.getValue().equalsIgnoreCase(GZIP)) {
        stream = new GZIPInputStream(stream);
    }
    String inputStreamString = new Scanner(stream, "UTF-8").useDelimiter("\\A").next();
    return inputStreamString;
}
 
开发者ID:DovAmir,项目名称:httpclientAuthHelper,代码行数:10,代码来源:AuthUtils.java

示例4: getResponseHeader

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
protected String getResponseHeader(HttpMethodBase method, String param)
{
   Header header = method.getResponseHeader(param);
   return (header == null ? null : header.getValue());
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:6,代码来源:NegotiationValidator.java

示例5: getLength

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
protected long getLength(HttpMethodBase method)
{
	Header header = method.getResponseHeader("Content-Length");
	return Long.parseLong(header.getValue());
}
 
开发者ID:hugomanguinhas,项目名称:europeana,代码行数:6,代码来源:DBPediaDatasetStat.java

示例6: getHeader

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
private static String getHeader(HttpMethodBase method, String headerName) {
    Header header = method.getResponseHeader(headerName);
    return (header == null) ? null : header.getValue().trim();
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:5,代码来源:CommonsHTTPSender.java

示例7: obtainHTTPHeaderInformation

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Collect the HTTP header information and set them in the message context
 *
 * @param method HttpMethodBase from which to get information
 * @param msgContext the MessageContext in which to place the information... OR NOT!
 * @throws AxisFault if problems occur
 */
protected void obtainHTTPHeaderInformation(HttpMethodBase method,
                                           MessageContext msgContext) throws AxisFault {
    // Set RESPONSE properties onto the REQUEST message context.  They will need to be copied off the request context onto
    // the response context elsewhere, for example in the OutInOperationClient.
    Map transportHeaders = new CommonsTransportHeaders(method.getResponseHeaders());
    msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, transportHeaders);
    msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE, new Integer(method.getStatusCode()));
    Header header = method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);

    if (header != null) {
        HeaderElement[] headers = header.getElements();
        MessageContext inMessageContext = msgContext.getOperationContext().getMessageContext(
                WSDLConstants.MESSAGE_LABEL_IN_VALUE);

        Object contentType = header.getValue();
        Object charSetEnc = null;

        for (int i = 0; i < headers.length; i++) {
            NameValuePair charsetEnc = headers[i].getParameterByName(
                    HTTPConstants.CHAR_SET_ENCODING);
            if (charsetEnc != null) {
                charSetEnc = charsetEnc.getValue();
            }
        }

        if (inMessageContext != null) {
            inMessageContext
                    .setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
            inMessageContext
                    .setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
        } else {

            // Transport details will be stored in a HashMap so that anybody interested can
            // retrieve them
            HashMap transportInfoMap = new HashMap();
            transportInfoMap.put(Constants.Configuration.CONTENT_TYPE, contentType);
            transportInfoMap.put(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);

            //the HashMap is stored in the outgoing message.
            msgContext.setProperty(Constants.Configuration.TRANSPORT_INFO_MAP,
                                   transportInfoMap);
        }
    }

    String sessionCookie = null;
    // Process old style headers first
    Header[] cookieHeaders = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE);
    String customCoookiId = (String) msgContext.getProperty(Constants.CUSTOM_COOKIE_ID);
    // process all the cookieHeaders, when load balancer is fronted it may require some cookies to function.
    sessionCookie = processCookieHeaders(cookieHeaders);

    // Overwrite old style cookies with new style ones if present
    cookieHeaders = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE2);
    for (int i = 0; i < cookieHeaders.length; i++) {
        HeaderElement[] elements = cookieHeaders[i].getElements();
        for (int e = 0; e < elements.length; e++) {
            HeaderElement element = elements[e];
            if (Constants.SESSION_COOKIE.equalsIgnoreCase(element.getName()) ||
                    Constants.SESSION_COOKIE_JSESSIONID.equalsIgnoreCase(element.getName())) {
                sessionCookie = processCookieHeader(element);
            }
            if(customCoookiId!=null&&customCoookiId.equalsIgnoreCase(element.getName())){
                sessionCookie = processCookieHeader(element);
            }
        }
    }

    if (sessionCookie != null && !sessionCookie.isEmpty()) {
        msgContext.getServiceContext().setProperty(HTTPConstants.COOKIE_STRING, sessionCookie);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:79,代码来源:AbstractHTTPSender.java

示例8: processResponse

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
protected void processResponse(HttpMethodBase httpMethod,
                               MessageContext msgContext)
        throws IOException {
    obtainHTTPHeaderInformation(httpMethod, msgContext);

    InputStream in = httpMethod.getResponseBodyAsStream();
    if (in == null) {
        if (hasResponseBodyForHTTPStatusCode(httpMethod.getStatusCode())) {
            throw new AxisFault(Messages.getMessage("canNotBeNull", "InputStream"));
        } else {
            in = new ByteArrayInputStream("".getBytes());
        }
    }
    Header contentEncoding =
            httpMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_ENCODING);
    if (contentEncoding != null) {
        if (contentEncoding.getValue().
                equalsIgnoreCase(HTTPConstants.COMPRESSION_GZIP)) {
            in = new GZIPInputStream(in);
            // If the content-encoding is identity we can basically ignore it.
        } else if (!"identity".equalsIgnoreCase(contentEncoding.getValue())) {
            throw new AxisFault("HTTP :" + "unsupported content-encoding of '"
                    + contentEncoding.getValue() + "' found");
        }
    }

    if (httpMethod.getStatusCode() == HttpStatus.SC_ACCEPTED) {
        Header contentLength = httpMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_LENGTH);
        boolean acceptedContainsBody = false;
        if (in.available() > 0 || (contentLength != null && Integer.parseInt(contentLength.getValue()) > 0)) {
            acceptedContainsBody = true;
        } else {
            Header transferEncoding = httpMethod.getResponseHeader(HTTPConstants.HEADER_TRANSFER_ENCODING);
            if (transferEncoding != null && transferEncoding.getValue().equals(
                    HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)) {
                String responseBody = httpMethod.getResponseBodyAsString();
                if (responseBody.length() > 0) {
                    acceptedContainsBody = true;
                    in = IOUtils.toInputStream(responseBody, "UTF-8");
                }
            }
        }
        if (!acceptedContainsBody) {
            /*
             * For HTTP 202 Accepted code, if the body is empty string then release connection.
             */
            httpMethod.releaseConnection();
            return;
        }
    }

    OperationContext opContext = msgContext.getOperationContext();
    if (opContext != null) {
        opContext.setProperty(MessageContext.TRANSPORT_IN, in);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:57,代码来源:AbstractHTTPSender.java

示例9: handleResponse

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Used to handle the HTTP Response
 *
 * @param msgContext - The MessageContext of the message
 * @param method     - The HTTP method used
 * @throws IOException - Thrown in case an exception occurs
 */
private void handleResponse(MessageContext msgContext,
                            HttpMethodBase method) throws IOException {
    int statusCode = method.getStatusCode();
    HTTPStatusCodeFamily family = getHTTPStatusCodeFamily(statusCode);
    log.trace("Handling response - " + statusCode);
    Set<Integer>nonErrorCodes = (Set<Integer>) msgContext.getProperty(HTTPConstants.NON_ERROR_HTTP_STATUS_CODES);    
    Set<Integer> errorCodes = new HashSet<Integer>();
    String strRetryErrorCodes = (String) msgContext.getProperty(HTTPConstants.ERROR_HTTP_STATUS_CODES); // Fixing
                                                                                            // ESBJAVA-3178
    if (strRetryErrorCodes != null && !strRetryErrorCodes.trim().equals("")) {
        for (String strRetryErrorCode : strRetryErrorCodes.split(",")) {
            try {
                errorCodes.add(Integer.valueOf(strRetryErrorCode));
            } catch (NumberFormatException e) {
                log.warn(strRetryErrorCode + " is not a valid status code");
            }
        }
    }
    if (HTTPStatusCodeFamily.SUCCESSFUL.equals(family)) {
        // Save the HttpMethod so that we can release the connection when cleaning up
        // HTTP 202 Accepted should support body based on ESBJAVA-4370 as spec does not strictly enforce
        // no-entity-body with 202 Accepted response.
        msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
        processResponse(method, msgContext);
    } else if (!errorCodes.contains(statusCode)
            && (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR
                    || statusCode == HttpStatus.SC_BAD_REQUEST || statusCode == HttpStatus.SC_CONFLICT)) {
        // Save the HttpMethod so that we can release the connection when cleaning up
        msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
        Header contenttypeHeader =
                method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
        String value = null;
        if (contenttypeHeader != null) {
            value = contenttypeHeader.getValue();
        }
         OperationContext opContext = msgContext.getOperationContext();
        if(opContext!=null){
            MessageContext inMessageContext =
                    opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            if(inMessageContext!=null){
                inMessageContext.setProcessingFault(true);
            }
        }
        if (value != null) {

            processResponse(method, msgContext);
        }
        
        if (org.apache.axis2.util.Utils.isClientThreadNonBlockingPropertySet(msgContext)) {
        	 throw new AxisFault(Messages.getMessage("transportError",
                     String.valueOf(statusCode),
                     method.getStatusText()));
        }
    } else if (nonErrorCodes != null && nonErrorCodes.contains(statusCode)) {
        msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
        processResponse(method, msgContext);
        return;
    } else {
        // Since we don't process the response, we must release the connection immediately
        method.releaseConnection();
        //solving CARBON-16056
        msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE, method.getStatusCode());
        AxisFault axisFault = new AxisFault(
                Messages.getMessage("transportError", String.valueOf(statusCode), method.getStatusText()),
                msgContext);
        axisFault.setFaultCode(String.valueOf(method.getStatusCode()));
        throw axisFault;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:77,代码来源:HTTPSender.java

示例10: getMosaic

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Makes a mosaic request and returns the resulting data in a MosaicResponse object.
 *
 * @param serviceUrl The URL of the NVCLDataService
 * @param logId The logID (from a getLogCollection request) to query
 * @param width [Optional] specify the number of column the images are to be displayed
 * @param startSampleNo [Optional] the first sample image to be displayed
 * @param endSampleNo [Optional] the last sample image to be displayed
 * @return
 */
public MosaicResponse getMosaic(String serviceUrl, String logId, Integer width, Integer startSampleNo, Integer endSampleNo) throws Exception {
    HttpMethodBase method = methodMaker.getMosaicMethod(serviceUrl, logId, width, startSampleNo, endSampleNo);

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

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

示例11: getPlotScalar

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Makes a plot scalar request and returns the resulting data in a PlotScalarResponse object.
 *
 * @param serviceUrl The URL of the NVCLDataService
 * @param logId The logID (from a getLogCollection request) to query
 * @param width [Optional] the width of the image in pixel
 * @param height [Optional] the height of the image in pixel
 * @param startDepth [Optional] the start depth of a borehole collar
 * @param endDepth [Optional] the end depth of a borehole collar
 * @param samplingInterval [Optional] the interval of the sampling
 * @param graphType [Optional] The type of graph to plot
 * @return
 */
public PlotScalarResponse getPlotScalar(String serviceUrl, String logId, Integer startDepth, Integer endDepth, Integer width, Integer height, Double samplingInterval, PlotScalarGraphType graphType) throws Exception {
    HttpMethodBase method = methodMaker.getPlotScalarMethod(serviceUrl, logId, startDepth, endDepth, width, height, samplingInterval, graphType);

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

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

示例12: getTSGDownload

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Makes a TSG download request and returns the resulting data in a TSGDownloadResponse object.
 *
 * One of (but not both) datasetId and matchString must be specified
 *
 * @param serviceUrl The URL of the NVCLDataService
 * @param email The user's email address
 * @param datasetId [Optional] a dataset id chosen by user (list of dataset id can be obtained thru calling the get log collection service)
 * @param matchString [Optional] Its value is part or all of a proper drillhole name. The first dataset found to match in the database is downloaded
 * @param lineScan [Optional] yes or no. If no then the main image component is not downloaded. The default is yes.
 * @param spectra [Optional] yes or no. If no then the spectral component is not downloaded. The default is yes.
 * @param profilometer [Optional] yes or no. If no then the profilometer component is not downloaded. The default is yes.
 * @param trayPics [Optional] yes or no. If no then the individual tray pictures are not downloaded. The default is yes.
 * @param mosaicPics [Optional] yes or no. If no then the hole mosaic picture is not downloaded. The default is yes.
 * @param mapPics [Optional] yes or no. If no then the map pictures are not downloaded. The default is yes.
 * @return
 */
public TSGDownloadResponse getTSGDownload(String serviceUrl, String email, String datasetId, String matchString, Boolean lineScan, Boolean spectra, Boolean profilometer, Boolean trayPics, Boolean mosaicPics, Boolean mapPics) throws Exception {
    HttpMethodBase method = methodMaker.getDownloadTSGMethod(serviceUrl, email, datasetId, matchString, lineScan, spectra, profilometer, trayPics, mosaicPics, mapPics);

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

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

示例13: checkTSGStatus

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Checks a user's TSG download status
 *
 * This method will return a HTML stream
 *
 * @param serviceUrl The URL of the NVCLDataService
 * @param email The user's email address
 * @return
 * @throws Exception
 */
public TSGStatusResponse checkTSGStatus(String serviceUrl, String email) throws Exception {
    HttpMethodBase method = methodMaker.getCheckTSGStatusMethod(serviceUrl, email);

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

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

示例14: getWFSDownload

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Begins a NVCL data service WFS download
 *
 * This method will return a HTML stream
 *
 * @param serviceUrl The URL of the NVCLDataService
 * @param email The user's email address
 * @param boreholeId selected borehole id (use as feature id for filtering purpose)
 * @param omUrl The valid url for the Observations and Measurements WFS
 * @param typeName The url parameter for the wfs request
 * @return
 * @throws Exception
 */
public WFSDownloadResponse getWFSDownload(String serviceUrl, String email, String boreholeId, String omUrl, String typeName) throws Exception {
    HttpMethodBase method = methodMaker.getDownloadWFSMethod(serviceUrl, email, boreholeId, omUrl, typeName);

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

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

示例15: checkWFSStatus

import org.apache.commons.httpclient.HttpMethodBase; //导入方法依赖的package包/类
/**
 * Checks a user's WFS download status
 *
 * This method will return a HTML stream
 *
 * @param serviceUrl The URL of the NVCLDataService
 * @param email The user's email address
 * @return
 * @throws Exception
 */
public WFSStatusResponse checkWFSStatus(String serviceUrl, String email) throws Exception {
    HttpMethodBase method = methodMaker.getCheckWFSStatusMethod(serviceUrl, email);

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

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


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