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


Java HttpServletResponse.SC_OK属性代码示例

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


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

示例1: getConsole

/**
 * Return a snapshot of the console.
 * 
 * @param subscription
 *            the valid screenshot of the console.
 * @return the valid screenshot of the console.
 */
@GET
@Path("{subscription:\\d+}/console.png")
@Produces("image/png")
public StreamingOutput getConsole(@PathParam("subscription") final int subscription) {
	final Map<String, String> parameters = subscriptionResource.getParameters(subscription);
	final VCloudCurlProcessor processor = new VCloudCurlProcessor();
	authenticate(parameters, processor);

	// Get the screen thumbnail
	return output -> {
		final String url = StringUtils.appendIfMissing(parameters.get(PARAMETER_API), "/") + "vApp/vm-" + parameters.get(PARAMETER_VM)
				+ "/screen";
		final CurlRequest curlRequest = new CurlRequest("GET", url, null, (request, response) -> {
			if (response.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK) {
				// Copy the stream
				IOUtils.copy(response.getEntity().getContent(), output);
				output.flush();
			}
			return false;
		});
		processor.process(curlRequest);
	};
}
 
开发者ID:ligoj,项目名称:plugin-vm-vcloud,代码行数:30,代码来源:VCloudPluginResource.java

示例2: resultConnection

/**
 *
 * @param httpURLConnection
 *            {@link HttpURLConnection}
 * @return HTTPResponse the http response
 * @throws IOException
 *             IOException from java.net
 */
protected HTTPResponse resultConnection(final HttpURLConnection httpURLConnection) throws IOException {
	final HTTPResponse ret = new HTTPResponse();

	ret.setResponseCode(httpURLConnection.getResponseCode());
	ret.setFinalURL(httpURLConnection.getURL());

	InputStream retStream;

	if (HttpServletResponse.SC_OK <= ret.getResponseCode()
			&& ret.getResponseCode() < HttpServletResponse.SC_BAD_REQUEST) {
		retStream = httpURLConnection.getInputStream();
	} else {
		retStream = httpURLConnection.getErrorStream();
	}
	ret.setContent(inputStreamToByte(retStream));

	fillHttpResponseHeader(ret, httpURLConnection.getHeaderFields());

	return ret;
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:28,代码来源:UrlFetchCommonHandler.java

示例3: doFilter

@Override
public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain filterChain) throws IOException, ServletException {
  KMSResponse kmsResponse = new KMSResponse(response);
  super.doFilter(request, kmsResponse, filterChain);

  if (kmsResponse.statusCode != HttpServletResponse.SC_OK &&
      kmsResponse.statusCode != HttpServletResponse.SC_CREATED &&
      kmsResponse.statusCode != HttpServletResponse.SC_UNAUTHORIZED) {
    KMSWebApp.getInvalidCallsMeter().mark();
  }

  // HttpServletResponse.SC_UNAUTHORIZED is because the request does not
  // belong to an authenticated user.
  if (kmsResponse.statusCode == HttpServletResponse.SC_UNAUTHORIZED) {
    KMSWebApp.getUnauthenticatedCallsMeter().mark();
    String method = ((HttpServletRequest) request).getMethod();
    StringBuffer requestURL = ((HttpServletRequest) request).getRequestURL();
    String queryString = ((HttpServletRequest) request).getQueryString();
    if (queryString != null) {
      requestURL.append("?").append(queryString);
    }

    KMSWebApp.getKMSAudit().unauthenticated(
        request.getRemoteHost(), method, requestURL.toString(),
        kmsResponse.msg);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:28,代码来源:KMSAuthenticationFilter.java

示例4: doTestNonLogin

public void doTestNonLogin(String uri, boolean useCookie,
            int expectedRC) throws Exception {

        Map<String,List<String>> reqHeaders =
                new HashMap<String,List<String>>();
        Map<String,List<String>> respHeaders =
                new HashMap<String,List<String>>();

        if (useCookie && (cookies != null)) {
            reqHeaders.put(CLIENT_COOKIE_HEADER, cookies);
        }

        ByteChunk bc = new ByteChunk();
        int rc = getUrl(HTTP_PREFIX + getPort() + uri, bc, reqHeaders,
                respHeaders);

        if (expectedRC != HttpServletResponse.SC_OK) {
            assertEquals(expectedRC, rc);
            assertTrue(bc.getLength() > 0);
        }
        else {
            assertEquals("OK", bc.toString());
        }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:TestSSOnonLoginAndBasicAuthenticator.java

示例5: logAndReturnException

/**
    * Clean return of Exception in JSon format & log Exception.
    * @param request
    * @param response
    * @param out
    * @param exception
    */
   public static void logAndReturnException(HttpServletRequest request, HttpServletResponse response, OutputStream out, Exception exception) {
try {

    JsonErrorReturn jsonErrorReturn = new JsonErrorReturn(
	    response,
	    HttpServletResponse.SC_OK,
	    JsonErrorReturn.ERROR_ACEQL_ERROR, exception.getMessage(), ExceptionUtils.getStackTrace(exception));

    ServerSqlManager.writeLine(out, jsonErrorReturn.build());
    LoggerUtil.log(request, exception);
    
} catch (Exception e) {
    // Should never happen
    e.printStackTrace();
}
   }
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:23,代码来源:ExceptionReturner.java

示例6: doTestNonLogin

private void doTestNonLogin(String uri, boolean useCookie,
        int expectedRC) throws Exception {

    Map<String,List<String>> reqHeaders =
            new HashMap<String,List<String>>();
    Map<String,List<String>> respHeaders =
            new HashMap<String,List<String>>();

    if (useCookie && (cookies != null)) {
        reqHeaders.put(CLIENT_COOKIE_HEADER, cookies);
    }

    ByteChunk bc = new ByteChunk();
    int rc = getUrl(HTTP_PREFIX + getPort() + uri, bc, reqHeaders,
            respHeaders);

    if (expectedRC != HttpServletResponse.SC_OK) {
        assertEquals(expectedRC, rc);
        assertTrue(bc.getLength() > 0);
    }
    else {
        assertEquals("OK", bc.toString());
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:24,代码来源:TestNonLoginAndBasicAuthenticator.java

示例7: onError

@Override
public void onError(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
                    Throwable exception, Span span) {
    Tags.ERROR.set(span, Boolean.TRUE);
    span.log(logsForException(exception));

    if (httpServletResponse.getStatus() == HttpServletResponse.SC_OK) {
        // exception is thrown in filter chain, but status code is incorrect
        Tags.HTTP_STATUS.set(span, 500);
    }
}
 
开发者ID:opentracing-contrib,项目名称:java-web-servlet-filter,代码行数:11,代码来源:ServletFilterSpanDecorator.java

示例8: nodes

@Operation("move")
@WebApiDescription(title = "Move Node",
        description="Moves one or more nodes (files or folders) to a new target folder, with option to rename.",
        successStatus = HttpServletResponse.SC_OK)
public Node moveById(String nodeId, NodeTarget target, Parameters parameters, WithResponse withResponse)
{
    return nodes.moveOrCopyNode(nodeId, target.getTargetParentId(), target.getName(), parameters, false);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:8,代码来源:NodesEntityResource.java

示例9: assertPageContains

private void assertPageContains(String pageUrl, String expectedBody,
        int expectedStatus) throws IOException {
    ByteChunk res = new ByteChunk();
    int sc = getUrl("http://localhost:" + getPort() + pageUrl, res, null);

    Assert.assertEquals(expectedStatus, sc);

    if (expectedStatus == HttpServletResponse.SC_OK) {
        String result = res.toString();
        Assert.assertTrue(result, result.indexOf(expectedBody) > -1);
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:12,代码来源:TestContextConfig.java

示例10: lock

@Operation("lock")
@WebApiDescription(title = "Lock Node",
        description="Places a lock on a node.",
        successStatus = HttpServletResponse.SC_OK)
public Node lock(String nodeId, LockInfo lockInfo, Parameters parameters, WithResponse withResponse)
{
    return nodes.lock(nodeId, lockInfo, parameters);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:8,代码来源:NodesEntityResource.java

示例11: doTestBasic

private void doTestBasic(String uri,
        TestSSOnonLoginAndBasicAuthenticator.BasicCredentials credentials,
        boolean useCookie, int expectedRC) throws Exception {

    Map<String,List<String>> reqHeaders = new HashMap<String,List<String>>();
    Map<String,List<String>> respHeaders = new HashMap<String,List<String>>();

    if (useCookie && (cookies != null)) {
        reqHeaders.put(CLIENT_COOKIE_HEADER, cookies);
    }
    else {
        if (credentials != null) {
            List<String> auth = new ArrayList<String>();
            auth.add(credentials.getCredentials());
            reqHeaders.put(CLIENT_AUTH_HEADER, auth);
        }
    }

    ByteChunk bc = new ByteChunk();
    int rc = getUrl(HTTP_PREFIX + getPort() + uri, bc, reqHeaders,
            respHeaders);

    assertEquals("Unexpected Return Code", expectedRC, rc);
    if (expectedRC != HttpServletResponse.SC_OK) {
        assertTrue(bc.getLength() > 0);
        if (expectedRC == HttpServletResponse.SC_UNAUTHORIZED) {
            // The server should identify the acceptable method(s)
            boolean methodFound = false;
            List<String> authHeaders = respHeaders.get(SERVER_AUTH_HEADER);
            for (String authHeader : authHeaders) {
                if (authHeader.indexOf(NICE_METHOD) > -1) {
                    methodFound = true;
                    break;
                }
            }
            assertTrue(methodFound);
        }
    }
    else {
        String thePage = bc.toString();
        assertNotNull(thePage);
        assertTrue(thePage.startsWith("OK"));
        if (useCookie) {
            List<String> newCookies = respHeaders.get(SERVER_COOKIE_HEADER);
            if (newCookies != null) {
                // harvest cookies whenever the server sends some new ones
                cookies = newCookies;
            }
        }
        else {
            encodedURL = "";
            final String start = "<a href=\"";
            final String end = "\">";
            int iStart = thePage.indexOf(start);
            int iEnd = 0;
            if (iStart > -1) {
                iStart += start.length();
                iEnd = thePage.indexOf(end, iStart);
                if (iEnd > -1) {
                    encodedURL = thePage.substring(iStart, iEnd);
                }
            }
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:65,代码来源:TestSSOnonLoginAndBasicAuthenticator.java

示例12: doTestBasic

private void doTestBasic(String uri, BasicCredentials credentials,
        boolean useCookie, int expectedRC) throws Exception {

    Map<String,List<String>> reqHeaders =
            new HashMap<String, List<String>>();
    Map<String,List<String>> respHeaders =
            new HashMap<String, List<String>>();

    if (useCookie && (cookies != null)) {
        reqHeaders.put(CLIENT_COOKIE_HEADER, cookies);
    }
    else {
        if (credentials != null) {
            List<String> auth = new ArrayList<String>();
            auth.add(credentials.getCredentials());
            reqHeaders.put(CLIENT_AUTH_HEADER, auth);
        }
    }

    ByteChunk bc = new ByteChunk();
    int rc = getUrl(HTTP_PREFIX + getPort() + uri, bc, reqHeaders,
            respHeaders);

    if (expectedRC != HttpServletResponse.SC_OK) {
        assertEquals(expectedRC, rc);
        assertTrue(bc.getLength() > 0);
        if (expectedRC == HttpServletResponse.SC_UNAUTHORIZED) {
            // The server should identify the acceptable method(s)
            boolean methodFound = false;
            List<String> authHeaders = respHeaders.get(SERVER_AUTH_HEADER);
            for (String authHeader : authHeaders) {
                if (authHeader.indexOf(NICE_METHOD) > -1) {
                    methodFound = true;
                    break;
                }
            }
            assertTrue(methodFound);
        }
    }
    else {
        assertEquals("OK", bc.toString());
        List<String> newCookies = respHeaders.get(SERVER_COOKIE_HEADER);
        if (newCookies != null) {
            // harvest cookies whenever the server sends some new ones
            cookies = newCookies;
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:48,代码来源:TestNonLoginAndBasicAuthenticator.java

示例13: validateStatusCode

private void validateStatusCode(SimpleHttpResponse httpResponse) throws InvalidResponseException {
    final int statusCode = httpResponse.getResponseCode();
    if (statusCode == HttpServletResponse.SC_OK) {
        return;
    }

    String errMessage = getErrorMessageByStatusCode(httpResponse.getRequestPath(), statusCode);
    errMessage += MessageFormat.format(ERROR_SERVICE_RETURN, statusCode, httpResponse.getResponseMessage());

    throw new InvalidResponseException(errMessage);
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:11,代码来源:DefaultHTTPResponseValidator.java

示例14: recycle

/**
 * Release all object references, and initialize instance variables, in
 * preparation for reuse of this object.
 */
public void recycle() {

    super.recycle();
    cookies.clear();
    headers.clear();
    message = getStatusMessage(HttpServletResponse.SC_OK);
    status = HttpServletResponse.SC_OK;

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:13,代码来源:HttpResponseBase.java

示例15: reset

/**
 * Clear any content written to the buffer.  In addition, all cookies
 * and headers are cleared, and the status is reset.
 *
 * @exception IllegalStateException if this response has already
 *  been committed
 */
public void reset() {

    if (included)
        return;     // Ignore any call from an included servlet

    super.reset();
    cookies.clear();
    headers.clear();
    message = null;
    status = HttpServletResponse.SC_OK;

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:19,代码来源:HttpResponseBase.java


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