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


Java MimeHeaders.getValue方法代码示例

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


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

示例1: isConnectionClose

import org.apache.tomcat.util.http.MimeHeaders; //导入方法依赖的package包/类
private boolean isConnectionClose(MimeHeaders headers) {
    MessageBytes connection = headers.getValue(Constants.CONNECTION);
    if (connection == null) {
        return false;
    }
    return connection.equals(Constants.CLOSE);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:8,代码来源:AbstractHttp11Processor.java

示例2: isConnectionClose

import org.apache.tomcat.util.http.MimeHeaders; //导入方法依赖的package包/类
private boolean isConnectionClose(MimeHeaders headers) {
	MessageBytes connection = headers.getValue(Constants.CONNECTION);
	if (connection == null) {
		return false;
	}
	return connection.equals(Constants.CLOSE);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:8,代码来源:AbstractHttp11Processor.java

示例3: prepareResponse

import org.apache.tomcat.util.http.MimeHeaders; //导入方法依赖的package包/类
/**
 * When committing the response, we have to validate the set of headers, as
 * well as setup the response filters.
 */
protected void prepareResponse()
    throws IOException {

    response.setCommitted(true);

    responseHeaderMessage.reset();
    responseHeaderMessage.appendByte(Constants.JK_AJP13_SEND_HEADERS);

    // HTTP header contents
    responseHeaderMessage.appendInt(response.getStatus());
    String message = null;
    if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER) {
        message = response.getMessage();
    }
    if (message == null){
        message = HttpMessages.getMessage(response.getStatus());
    } else {
        message = message.replace('\n', ' ').replace('\r', ' ');
    }
    if (message == null) {
        // Many httpd 2.x wants a non empty status message
        message = Integer.toString(response.getStatus());
    }
    tmpMB.setString(message);
    responseHeaderMessage.appendBytes(tmpMB);

    // Special headers
    MimeHeaders headers = response.getMimeHeaders();
    String contentType = response.getContentType();
    if (contentType != null) {
        headers.setValue("Content-Type").setString(contentType);
    }
    String contentLanguage = response.getContentLanguage();
    if (contentLanguage != null) {
        headers.setValue("Content-Language").setString(contentLanguage);
    }
    int contentLength = response.getContentLength();
    if (contentLength >= 0) {
        headers.setValue("Content-Length").setInt(contentLength);
    }

    // Other headers
    int numHeaders = headers.size();
    responseHeaderMessage.appendInt(numHeaders);
    for (int i = 0; i < numHeaders; i++) {            
        MessageBytes hN = headers.getName(i);
        int hC = Constants.getResponseAjpIndex(hN.toString());
        if (hC > 0) {
            responseHeaderMessage.appendInt(hC);
        }
        else {
            responseHeaderMessage.appendBytes(hN);
        }
        MessageBytes hV=headers.getValue(i);
        responseHeaderMessage.appendBytes(hV);
    }

    // Write to buffer
    responseHeaderMessage.end();
    outputBuffer.put(responseHeaderMessage.getBuffer(), 0, responseHeaderMessage.getLen());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:67,代码来源:AjpAprProcessor.java

示例4: prepareResponse

import org.apache.tomcat.util.http.MimeHeaders; //导入方法依赖的package包/类
/**
 * When committing the response, we have to validate the set of headers, as
 * well as setup the response filters.
 */
protected void prepareResponse()
    throws IOException {

    response.setCommitted(true);

    responseHeaderMessage.reset();
    responseHeaderMessage.appendByte(Constants.JK_AJP13_SEND_HEADERS);

    // HTTP header contents
    responseHeaderMessage.appendInt(response.getStatus());
    String message = null;
    if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER) {
        message = response.getMessage();
    }
    if (message == null){
        message = HttpMessages.getMessage(response.getStatus());
    } else {
        message = message.replace('\n', ' ').replace('\r', ' ');
    }
    if (message == null) {
        // Many httpd 2.x wants a non empty status message
        message = Integer.toString(response.getStatus());
    }
    tmpMB.setString(message);
    responseHeaderMessage.appendBytes(tmpMB);

    // Special headers
    MimeHeaders headers = response.getMimeHeaders();
    String contentType = response.getContentType();
    if (contentType != null) {
        headers.setValue("Content-Type").setString(contentType);
    }
    String contentLanguage = response.getContentLanguage();
    if (contentLanguage != null) {
        headers.setValue("Content-Language").setString(contentLanguage);
    }
    int contentLength = response.getContentLength();
    if (contentLength >= 0) {
        headers.setValue("Content-Length").setInt(contentLength);
    }

    // Other headers
    int numHeaders = headers.size();
    responseHeaderMessage.appendInt(numHeaders);
    for (int i = 0; i < numHeaders; i++) {
        MessageBytes hN = headers.getName(i);
        int hC = Constants.getResponseAjpIndex(hN.toString());
        if (hC > 0) {
            responseHeaderMessage.appendInt(hC);
        }
        else {
            responseHeaderMessage.appendBytes(hN);
        }
        MessageBytes hV=headers.getValue(i);
        responseHeaderMessage.appendBytes(hV);
    }

    // Write to buffer
    responseHeaderMessage.end();
    output.write(responseHeaderMessage.getBuffer(), 0, responseHeaderMessage.getLen());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:67,代码来源:AjpProcessor.java

示例5: prepareResponse

import org.apache.tomcat.util.http.MimeHeaders; //导入方法依赖的package包/类
/**
 * When committing the response, we have to validate the set of headers, as
 * well as setup the response filters.
 */
protected void prepareResponse() throws IOException {

	response.setCommitted(true);

	responseMessage.reset();
	responseMessage.appendByte(Constants.JK_AJP13_SEND_HEADERS);

	// Responses with certain status codes are not permitted to include a
	// response body.
	int statusCode = response.getStatus();
	if (statusCode < 200 || statusCode == 204 || statusCode == 205 || statusCode == 304) {
		// No entity body
		swallowResponse = true;
	}

	// Responses to HEAD requests are not permitted to incude a response
	// body.
	MessageBytes methodMB = request.method();
	if (methodMB.equals("HEAD")) {
		// No entity body
		swallowResponse = true;
	}

	// HTTP header contents
	responseMessage.appendInt(statusCode);
	String message = null;
	if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER
			&& HttpMessages.isSafeInHttpHeader(response.getMessage())) {
		message = response.getMessage();
	}
	if (message == null) {
		message = HttpMessages.getInstance(response.getLocale()).getMessage(response.getStatus());
	}
	if (message == null) {
		// mod_jk + httpd 2.x fails with a null status message - bug 45026
		message = Integer.toString(response.getStatus());
	}
	tmpMB.setString(message);
	responseMessage.appendBytes(tmpMB);

	// Special headers
	MimeHeaders headers = response.getMimeHeaders();
	String contentType = response.getContentType();
	if (contentType != null) {
		headers.setValue("Content-Type").setString(contentType);
	}
	String contentLanguage = response.getContentLanguage();
	if (contentLanguage != null) {
		headers.setValue("Content-Language").setString(contentLanguage);
	}
	long contentLength = response.getContentLengthLong();
	if (contentLength >= 0) {
		headers.setValue("Content-Length").setLong(contentLength);
	}

	// Other headers
	int numHeaders = headers.size();
	responseMessage.appendInt(numHeaders);
	for (int i = 0; i < numHeaders; i++) {
		MessageBytes hN = headers.getName(i);
		int hC = Constants.getResponseAjpIndex(hN.toString());
		if (hC > 0) {
			responseMessage.appendInt(hC);
		} else {
			responseMessage.appendBytes(hN);
		}
		MessageBytes hV = headers.getValue(i);
		responseMessage.appendBytes(hV);
	}

	// Write to buffer
	responseMessage.end();
	output(responseMessage.getBuffer(), 0, responseMessage.getLen());
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:79,代码来源:AbstractAjpProcessor.java

示例6: replaceCookie

import org.apache.tomcat.util.http.MimeHeaders; //导入方法依赖的package包/类
protected void replaceCookie(Request request, Response response, Cookie cookie) {

        Delegator delegator = (Delegator) request.getAttribute("delegator");
        // copy the existing session cookie, but use a different domain (only if domain is valid)
        String cookieDomain = null;
        cookieDomain = EntityUtilProperties.getPropertyValue("url", "cookie.domain", "", delegator);

        if (UtilValidate.isEmpty(cookieDomain)) {
            String serverName = request.getServerName();
            String[] domainArray = serverName.split("\\.");
            // check that the domain isn't an IP address
            if (domainArray.length == 4) {
                boolean isIpAddress = true;
                for (String domainSection : domainArray) {
                    if (!UtilValidate.isIntegerInRange(domainSection, 0, 255)) {
                        isIpAddress = false;
                        break;
                    }
                }
                if (isIpAddress) return;
            }
            if (domainArray.length > 2) {
                cookieDomain = "." + domainArray[domainArray.length - 2] + "." + domainArray[domainArray.length - 1];
            }
        }


        if (UtilValidate.isNotEmpty(cookieDomain)) {
            Cookie newCookie = new Cookie(cookie.getName(), cookie.getValue());
            if (cookie.getPath() != null) {
                newCookie.setPath(cookie.getPath());
            }
            newCookie.setDomain(cookieDomain);
            newCookie.setMaxAge(cookie.getMaxAge());
            newCookie.setVersion(cookie.getVersion());
            if (cookie.getComment() != null) {
                newCookie.setComment(cookie.getComment());
            }
            newCookie.setSecure(cookie.getSecure());

            // if the response has already been committed, our replacement strategy will have no effect
            if (response.isCommitted()) {
                Debug.logError("CrossSubdomainSessionValve: response was already committed!", module);
            }

            // find the Set-Cookie header for the existing cookie and replace its value with new cookie
            MimeHeaders mimeHeaders = request.getCoyoteRequest().getMimeHeaders();
            for (int i = 0, size = mimeHeaders.size(); i < size; i++) {
                if (mimeHeaders.getName(i).equals("Set-Cookie")) {
                    MessageBytes value = mimeHeaders.getValue(i);
                    if (value.indexOf(cookie.getName()) >= 0) {
                        String newCookieValue = request.getContext().getCookieProcessor().generateHeader(newCookie);
                        Debug.logVerbose("CrossSubdomainSessionValve: old Set-Cookie value: " + value.toString(), module);
                        Debug.logVerbose("CrossSubdomainSessionValve: new Set-Cookie value: " + newCookieValue, module);
                        value.setString(newCookieValue);
                    }
                }
            }
        }
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:61,代码来源:CrossSubdomainSessionValve.java

示例7: replaceCookie

import org.apache.tomcat.util.http.MimeHeaders; //导入方法依赖的package包/类
protected void replaceCookie(Request request, Response response, Cookie cookie) {

        // copy the existing session cookie, but use a different domain (only if domain is valid)
        String cookieDomain = null;
        cookieDomain = UtilProperties.getPropertyValue("url", "cookie.domain", "");

        if (UtilValidate.isEmpty(cookieDomain)) {
            String serverName = request.getServerName();
            String[] domainArray = serverName.split("\\.");
            // check that the domain isn't an IP address
            if (domainArray.length == 4) {
                boolean isIpAddress = true;
                for (String domainSection : domainArray) {
                    if (!UtilValidate.isIntegerInRange(domainSection, 0, 255)) {
                        isIpAddress = false;
                        break;
                    }
                }
                if (isIpAddress) return;
            }
            if (domainArray.length > 2) {
                cookieDomain = "." + domainArray[domainArray.length - 2] + "." + domainArray[domainArray.length - 1];
            }
        }


        if (UtilValidate.isNotEmpty(cookieDomain)) {
            Cookie newCookie = new Cookie(cookie.getName(), cookie.getValue());
            if (cookie.getPath() != null) {
                newCookie.setPath(cookie.getPath());
            }
            newCookie.setDomain(cookieDomain);
            newCookie.setMaxAge(cookie.getMaxAge());
            newCookie.setVersion(cookie.getVersion());
            if (cookie.getComment() != null) {
                newCookie.setComment(cookie.getComment());
            }
            newCookie.setSecure(cookie.getSecure());

            // if the response has already been committed, our replacement strategy will have no effect
            if (response.isCommitted()) {
                Debug.logError("CrossSubdomainSessionValve: response was already committed!", module);
            }

            // find the Set-Cookie header for the existing cookie and replace its value with new cookie
            MimeHeaders mimeHeaders = request.getCoyoteRequest().getMimeHeaders();
            for (int i = 0, size = mimeHeaders.size(); i < size; i++) {
                if (mimeHeaders.getName(i).equals("Set-Cookie")) {
                    MessageBytes value = mimeHeaders.getValue(i);
                    if (value.indexOf(cookie.getName()) >= 0) {
                        StringBuffer buffer = new StringBuffer();
                        ServerCookie.appendCookieValue(buffer, newCookie.getVersion(), newCookie.getName(), newCookie.getValue(), newCookie.getPath(),
                                newCookie.getDomain(), newCookie.getComment(), newCookie.getMaxAge(), newCookie.getSecure(), true);
                        Debug.logVerbose("CrossSubdomainSessionValve: old Set-Cookie value: " + value.toString(), module);
                        Debug.logVerbose("CrossSubdomainSessionValve: new Set-Cookie value: " + buffer, module);
                        value.setString(buffer.toString());
                    }
                }
            }
        }
    }
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:62,代码来源:CrossSubdomainSessionValve.java

示例8: prepareResponse

import org.apache.tomcat.util.http.MimeHeaders; //导入方法依赖的package包/类
/**
 * When committing the response, we have to validate the set of headers, as
 * well as setup the response filters.
 */
protected void prepareResponse() throws IOException {

    response.setCommitted(true);

    responseMessage.reset();
    responseMessage.appendByte(Constants.JK_AJP13_SEND_HEADERS);

    // HTTP header contents
    responseMessage.appendInt(response.getStatus());
    String message = null;
    if (org.apache.coyote.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER &&
            HttpMessages.isSafeInHttpHeader(response.getMessage())) {
        message = response.getMessage();
    }
    if (message == null){
        message = HttpMessages.getMessage(response.getStatus());
    }
    if (message == null) {
        // mod_jk + httpd 2.x fails with a null status message - bug 45026
        message = Integer.toString(response.getStatus());
    }
    tmpMB.setString(message);
    responseMessage.appendBytes(tmpMB);

    // Special headers
    MimeHeaders headers = response.getMimeHeaders();
    String contentType = response.getContentType();
    if (contentType != null) {
        headers.setValue("Content-Type").setString(contentType);
    }
    String contentLanguage = response.getContentLanguage();
    if (contentLanguage != null) {
        headers.setValue("Content-Language").setString(contentLanguage);
    }
    long contentLength = response.getContentLengthLong();
    if (contentLength >= 0) {
        headers.setValue("Content-Length").setLong(contentLength);
    }

    // Other headers
    int numHeaders = headers.size();
    responseMessage.appendInt(numHeaders);
    for (int i = 0; i < numHeaders; i++) {
        MessageBytes hN = headers.getName(i);
        int hC = Constants.getResponseAjpIndex(hN.toString());
        if (hC > 0) {
            responseMessage.appendInt(hC);
        }
        else {
            responseMessage.appendBytes(hN);
        }
        MessageBytes hV=headers.getValue(i);
        responseMessage.appendBytes(hV);
    }

    // Write to buffer
    responseMessage.end();
    output(responseMessage.getBuffer(), 0,
            responseMessage.getLen());
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:65,代码来源:AbstractAjpProcessor.java


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