本文整理了Java中org.apache.catalina.connector.Response
类的一些代码示例,展示了Response
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response
类的具体详情如下:
包路径:org.apache.catalina.connector.Response
类名称:Response
[英]Wrapper object for the Coyote response.
[中]Coyote响应的包装器对象。
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@Override
public void sendError(int sc)
throws IOException {
if (isCommitted()) {
throw new IllegalStateException
(sm.getString("coyoteResponse.sendError.ise"));
}
response.setAppCommitted(true);
response.sendError(sc);
}
代码示例来源:origin: com.springsource.insight/insight-collection-tcserver
String parseReasonPhrase(Response response) {
String msg = response.getMessage();
if (msg != null) {
return msg;
}
return statusReasons.getString("sc." + response.getStatus());
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@Override
public void sendRedirect(String location)
throws IOException {
if (isCommitted()) {
throw new IllegalStateException
(sm.getString("coyoteResponse.sendRedirect.ise"));
}
response.setAppCommitted(true);
response.sendRedirect(location);
}
代码示例来源:origin: tomcat/catalina
/**
* Reset this response, and specify the values for the HTTP status code
* and corresponding message.
*
* @exception IllegalStateException if this response has already been
* committed
*/
public void reset(int status, String message) {
reset();
setStatus(status, message);
}
代码示例来源:origin: org.jboss.resteasy/skeleton-key-as7
protected void basicAuthError(Response response) throws IOException
{
response.setHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"" + context.getLoginConfig().getRealmName() + "\"");
response.sendError(401);
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
ErrorPage errorPage) {
if (container.getLogger().isDebugEnabled()) {
container.getLogger().debug("Processing " + errorPage);
request.getContext().getServletContext();
RequestDispatcher rd =
servletContext.getRequestDispatcher(errorPage.getLocation());
container.getLogger().error(
sm.getString("standardHostValue.customStatusFailed", errorPage.getLocation()));
return false;
if (response.isCommitted()) {
rd.include(request.getRequest(), response.getResponse());
} else {
response.resetBuffer(true);
response.setContentLength(-1);
rd.forward(request.getRequest(), response.getResponse());
response.setSuspended(false);
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
MessageBytes requestPathMB = request.getRequestPathMB();
if ((requestPathMB.startsWithIgnoreCase("/META-INF/", 0))
|| (requestPathMB.equalsIgnoreCase("/META-INF"))
|| (requestPathMB.startsWithIgnoreCase("/WEB-INF/", 0))
|| (requestPathMB.equalsIgnoreCase("/WEB-INF"))) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
Wrapper wrapper = request.getWrapper();
if (wrapper == null || wrapper.isUnavailable()) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
response.sendAcknowledgement();
} catch (IOException ioe) {
container.getLogger().error(sm.getString(
"standardContextValve.acknowledgeException"), ioe);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, ioe);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
request.setAsyncSupported(wrapper.getPipeline().isAsyncSupported());
wrapper.getPipeline().getFirst().invoke(request, response);
代码示例来源:origin: org.picketlink/picketlink-tomcat-common
public Principal authenticateSSL(Request request, Response response) throws IOException {
if (containerLog.isDebugEnabled()) {
containerLog.debug(" Looking up certificates");
X509Certificate[] certs = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR);
request.getCoyoteRequest().action(ActionCode.ACTION_REQ_SSL_CERTIFICATE, null);
} catch (IllegalStateException ise) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, sm.getString("authenticator.certificates"));
return null;
certs = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR);
if (containerLog.isDebugEnabled()) {
containerLog.debug(" No certificates included with this request");
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, sm.getString("authenticator.certificates"));
return null;
Principal principal = getContext().getRealm().authenticate(certs);
containerLog.debug(" Realm.authenticate() returned false");
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, sm.getString("authenticator.unauthorized"));
return null;
代码示例来源:origin: chexagon/redis-session-manager
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
Context context = request.getContext();
if (context == null) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, sm.getString("standardHost.noContext"));
return;
}
Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader());
boolean processed = false;
try {
if (ignorePattern == null || !ignorePattern.matcher(request.getRequestURI()).matches()) {
processed = true;
if (log.isTraceEnabled()) {
log.trace("Will save to redis after request for [" + getQueryString(request) + "]");
}
} else {
if (log.isTraceEnabled()) {
log.trace("Ignoring [" + getQueryString(request) + "]");
}
}
getNext().invoke(request, response);
} finally {
manager.afterRequest(processed);
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@Override
public AsyncContext startAsync(ServletRequest request,
ServletResponse response) {
if (!isAsyncSupported()) {
IllegalStateException ise =
new IllegalStateException(sm.getString("request.asyncNotSupported"));
log.warn(sm.getString("coyoteRequest.noAsync",
StringUtils.join(getNonAsyncClassNames())), ise);
throw ise;
}
if (asyncContext == null) {
asyncContext = new AsyncContextImpl(this);
}
asyncContext.setStarted(getContext(), request, response,
request==getRequest() && response==getResponse().getResponse());
asyncContext.setTimeout(getConnector().getAsyncTimeout());
return asyncContext;
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
if (isCommitted()) {
throw new IllegalStateException(sm.getString("coyoteResponse.sendRedirect.ise"));
resetBuffer(true);
String locationUri;
if (getRequest().getCoyoteRequest().getSupportsRelativeRedirects() &&
getContext().getUseRelativeRedirects()) {
locationUri = location;
} else {
locationUri = toAbsolute(location);
setStatus(status);
setHeader("Location", locationUri);
if (getContext().getSendRedirectBody()) {
PrintWriter writer = getWriter();
writer.print(sm.getString("coyoteResponse.sendRedirect.note",
Escape.htmlElementContent(locationUri)));
flushBuffer();
log.warn(sm.getString("response.sendRedirectFail", location), e);
setStatus(SC_NOT_FOUND);
setSuspended(true);
代码示例来源:origin: codefollower/Tomcat-Research
/**
* Select the appropriate child Host to process this request,
* based on the requested server name. If no matching Host can
* be found, return an appropriate HTTP error.
*
* @param request Request to be processed
* @param response Response to be produced
*
* @exception IOException if an input/output error occurred
* @exception ServletException if a servlet error occurred
*/
@Override
public final void invoke(Request request, Response response)
throws IOException, ServletException {
// Select the Host to be used for this Request
Host host = request.getHost();
if (host == null) {
response.sendError
(HttpServletResponse.SC_BAD_REQUEST,
sm.getString("standardEngine.noHost",
request.getServerName()));
return;
}
if (request.isAsyncSupported()) {
request.setAsyncSupported(host.getPipeline().isAsyncSupported());
}
// Ask this Host to process this request
host.getPipeline().getFirst().invoke(request, response);
}
代码示例来源:origin: jboss.web/jbossweb
ErrorPage errorPage) {
if (container.getLogger().isDebugEnabled())
container.getLogger().debug("Processing " + errorPage);
request.setPathInfo(errorPage.getLocation());
response.resetBuffer(true);
request.getContext().getServletContext();
RequestDispatcher rd =
servletContext.getRequestDispatcher(errorPage.getLocation());
rd.forward(request.getRequest(), response.getResponse());
response.setSuspended(false);
container.getLogger().error("Exception Processing " + errorPage, t);
return (false);
代码示例来源:origin: org.wso2.appserver/appserver-webapp-security
try {
if (requestResolver.isHttpPOSTBinding()) {
if (request.getSession(false).getAttribute(Constants.SESSION_BEAN) != null) {
String htmlPayload = manager.handleLogoutRequestForPOSTBinding(request);
response.setContentType(Constants.CONTENT_TYPE_HTML);
SSOUtils.sendCharacterData(response, htmlPayload);
} else {
containerLog.warn("Attempt to logout from an already logged out session");
response.sendRedirect(request.getContext().getPath());
response.sendRedirect(manager.handleLogoutRequestForRedirectBinding(request));
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
private JaspicState getJaspicState(AuthConfigProvider jaspicProvider, Request request,
Response response, boolean authMandatory) throws IOException {
JaspicState jaspicState = new JaspicState();
jaspicState.messageInfo =
new MessageInfoImpl(request.getRequest(), response.getResponse(), authMandatory);
try {
CallbackHandler callbackHandler = createCallbackHandler();
ServerAuthConfig serverAuthConfig = jaspicProvider.getServerAuthConfig(
"HttpServlet", jaspicAppContextID, callbackHandler);
String authContextID = serverAuthConfig.getAuthContextID(jaspicState.messageInfo);
jaspicState.serverAuthContext = serverAuthConfig.getAuthContext(authContextID, null, null);
} catch (AuthException e) {
log.warn(sm.getString("authenticator.jaspicServerAuthContextFail"), e);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return null;
}
return jaspicState;
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
private boolean sendErrorPage(String location, Response response) {
File file = new File(location);
if (!file.isAbsolute()) {
file = new File(getContainer().getCatalinaBase(), location);
}
if (!file.isFile() || !file.canRead()) {
getContainer().getLogger().warn(
sm.getString("errorReportValve.errorPageNotFound", location));
return false;
}
// Hard coded for now. Consider making this optional. At Valve level or
// page level?
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
try (OutputStream os = response.getOutputStream();
InputStream is = new FileInputStream(file);){
IOTools.flow(is, os);
} catch (IOException e) {
getContainer().getLogger().warn(
sm.getString("errorReportValve.errorPageIOException", location), e);
return false;
}
return true;
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@Override
public void invoke(final Request request, final Response response) throws IOException, ServletException {
if (isAllowed(request.getRequest().getRemoteAddr())) {
getNext().invoke(request, response);
} else {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
}
代码示例来源:origin: apache/meecrowave
@Override
public void invoke(final Request request, final Response response) throws IOException, ServletException {
if (request.getRequestURI().equals(current.endpoint)) {
response.setHeader("Content-Type", "text/plain");
response.getWriter().write(current.challenge);
return;
}
getNext().invoke(request, response);
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
/**
* Reject the request that was denied by this valve.
* <p>If <code>invalidAuthenticationWhenDeny</code> is true
* and the context has <code>preemptiveAuthentication</code>
* set, set an invalid authorization header to trigger basic auth.
*
* @param request The servlet request to be processed
* @param response The servlet response to be processed
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
protected void denyRequest(Request request, Response response)
throws IOException, ServletException {
if (invalidAuthenticationWhenDeny) {
Context context = request.getContext();
if (context != null && context.getPreemptiveAuthentication()) {
if (request.getCoyoteRequest().getMimeHeaders().getValue("authorization") == null) {
request.getCoyoteRequest().getMimeHeaders().addValue("authorization").setString("invalid");
}
getNext().invoke(request, response);
return;
}
}
response.sendError(denyStatus);
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
/**
* Special method for adding a session cookie as we should be overriding
* any previous.
*
* @param cookie The new session cookie to add the response
*/
public void addSessionCookieInternal(final Cookie cookie) {
if (isCommitted()) {
return;
}
String name = cookie.getName();
final String headername = "Set-Cookie";
final String startsWith = name + "=";
String header = generateCookieString(cookie);
boolean set = false;
MimeHeaders headers = getCoyoteResponse().getMimeHeaders();
int n = headers.size();
for (int i = 0; i < n; i++) {
if (headers.getName(i).toString().equals(headername)) {
if (headers.getValue(i).toString().startsWith(startsWith)) {
headers.getValue(i).setString(header);
set = true;
}
}
}
if (!set) {
addHeader(headername, header);
}
}
内容来源于网络,如有侵权,请联系作者删除!