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


Java Response.sendError方法代码示例

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


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

示例1: setResponse

import org.glassfish.grizzly.http.server.Response; //导入方法依赖的package包/类
protected void setResponse(final Response response, final int status) {
  try {
    response.sendError(status);
  } catch (final IOException e) {
    LOG.error("\n", e);
  }
  response.finish();
}
 
开发者ID:dice-group,项目名称:FOX,代码行数:9,代码来源:FeedbackHttpHandler.java

示例2: sendError

import org.glassfish.grizzly.http.server.Response; //导入方法依赖的package包/类
private void sendError(final Response response, final int status) {
  try {
    response.sendError(status);
  } catch (final IOException e) {
    LOG.error(e.getLocalizedMessage(), e);
  }
  response.finish();
}
 
开发者ID:dice-group,项目名称:FOX,代码行数:9,代码来源:AbstractFoxHttpHandler.java

示例3: service

import org.glassfish.grizzly.http.server.Response; //导入方法依赖的package包/类
/***************************************************************************
    *                                                                         *
    * Public methods                                                          *
    *                                                                         *
    **************************************************************************/


   @Override
public void service(Request request, Response response) throws Exception {
	String requestUri = getRelativeURI(request);
	ResourceLocation resource = getStreamResource(request, response, requestUri);
	if(resource != null){
		sendStream(request, response, resource);
	}else{
		response.sendError(404);
	}
}
 
开发者ID:Vidada-Project,项目名称:vidada-desktop,代码行数:18,代码来源:SeekableHttpHandler.java

示例4: Server

import org.glassfish.grizzly.http.server.Response; //导入方法依赖的package包/类
public Server(PropertiesConfiguration properties) throws IOException {
	m_properties = properties;
	m_httpServer = new HttpServer();
	
	int port = properties.getInt(PROPERTY_PORT, DEFAULT_PORT);
	String host = properties.getString(PROPERTY_HOST, DEFAULT_HOST);
	final NetworkListener networkListener = new NetworkListener(
			NET_LISTENER_NAME,
			host,
			port);

	// Enable SSL on the listener
	networkListener.setSecure(true);
	networkListener.setSSLEngineConfig(makeSSLConfig(m_properties));

	CompressionConfig compressionConfig =
	        networkListener.getCompressionConfig();
	compressionConfig.setCompressionMode(CompressionConfig.CompressionMode.ON); // the mode
	compressionConfig.setCompressionMinSize(100); // the min amount of bytes to compress
	compressionConfig.setCompressableMimeTypes("text/plain", "text/html", "application/x-protobuf", "application/pdf"); // the mime types to compress
	
	m_httpServer.addListener(networkListener);
	

	// Create a concurrent, nonblocking, asynchronous, batching JPA-based store for persistence
	// of request data. Async is OK, as persistence failures do not need to be handled by the client.
	m_store = new JPABatchStore(ConfigurationConverter.getMap(m_properties));
	m_batchPersister = new AsyncConcurrentBatchingProcessor<PersistEntityEvent>(
			m_store,
			PersistEntityEvent::new,
			PersistEntityEvent::translate
			);

	final ServerConfiguration config = m_httpServer.getServerConfiguration();

	config.setMaxPostSize(MAX_POST_SIZE);
	AsyncPostHandler.ErrorHandler errorHandler = 
			(ByteBuffer postBytes, Response resp, Throwable t) -> {
				LogManager.getLogger(this).warn("Invalid submission.", t);
				resp.sendError(300);
				resp.finish();
			};

	AsyncPostHandler certHandler = 
			new AsyncPostHandler(new CertificateHandler(m_batchPersister, CERT_TEMPLATE_PATH, errorHandler),
					errorHandler);
	
	
	AsyncPostHandler versionHandler =
			new AsyncPostHandler(new VersionCheckHandler(m_batchPersister, properties), errorHandler);
	config.addHttpHandler(certHandler, PATH_SUBMIT);
	config.addHttpHandler(versionHandler, PATH_VERSION_CHECK);
	
}
 
开发者ID:davruet,项目名称:shenanigans.io,代码行数:55,代码来源:Server.java

示例5: service

import org.glassfish.grizzly.http.server.Response; //导入方法依赖的package包/类
@Override
public void service(Request request, Response response) 
throws Exception 
{
    String uri = request.getRequestURI();
    
    int pos = uri.lastIndexOf('.');
    String extension = uri.substring(pos + 1);
    String mediaType = EXTENSION_TO_MEDIA_TYPE.get(extension);

    if (!uri.equals("/") && ( uri.contains("..") || mediaType == null) ) {
        response.sendError(HttpStatus.NOT_FOUND_404.getStatusCode());
        return;
    }
    
    final String resourcesContextPath = request.getContextPath();
    if (resourcesContextPath != null && !resourcesContextPath.isEmpty()) {
        if (!uri.startsWith(resourcesContextPath)) {
            response.sendError(HttpStatus.NOT_FOUND_404.getStatusCode());
            return;
        }

        uri = uri.substring(resourcesContextPath.length());
    }

    uri = uri.equals("/") ? uri.concat("index.html") : uri;
    System.out.println(uri);
    InputStream fileStream;

    try {
        fileStream = webRootPath == null ?
                Server.class.getResourceAsStream(WEB_ROOT + uri) :
                new FileInputStream(webRootPath + uri);
    } catch (IOException e) {
        fileStream = null;
    }
    if (fileStream == null) {
        response.sendError(HttpStatus.NOT_FOUND_404.getStatusCode());
    } else {
        response.setStatus(HttpStatus.OK_200);
        response.setContentType(mediaType);
        ReaderWriter.writeTo(fileStream, response.getOutputStream());
    }
}
 
开发者ID:giusepperizzo,项目名称:geosummly,代码行数:45,代码来源:Server.java


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