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


Java AsyncHttpServerResponse.code方法代码示例

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


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

示例1: WebSocketImpl

import com.koushikdutta.async.http.server.AsyncHttpServerResponse; //导入方法依赖的package包/类
public WebSocketImpl(AsyncHttpServerRequest request, AsyncHttpServerResponse response) {
        this(request.getSocket());
        
        String key = request.getHeaders().get("Sec-WebSocket-Key");
        String concat = key + MAGIC;
        String sha1 = SHA1(concat);
        String origin = request.getHeaders().get("Origin");
        
        response.code(101);
        response.getHeaders().set("Upgrade", "WebSocket");
        response.getHeaders().set("Connection", "Upgrade");
        response.getHeaders().set("Sec-WebSocket-Accept", sha1);
        String protocol = request.getHeaders().get("Sec-WebSocket-Protocol");
        // match the protocol (sanity checking and enforcement is done in the caller)
        if (!TextUtils.isEmpty(protocol))
            response.getHeaders().set("Sec-WebSocket-Protocol", protocol);
//        if (origin != null)
//            response.getHeaders().getHeaders().set("Access-Control-Allow-Origin", "http://" + origin);
        response.writeHead();
        
        setupParser(false, false);
    }
 
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:23,代码来源:WebSocketImpl.java

示例2: onRequest

import com.koushikdutta.async.http.server.AsyncHttpServerResponse; //导入方法依赖的package包/类
public void onRequest(AsyncHttpServerRequest request, AsyncHttpServerResponse response) {
    if (true) {
        Log.i(Main.TAG, "screenshot authentication success");
        try {
            Bitmap bitmap = EncoderFeeder.screenshot(this.val$wm);
            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bout);
            bout.flush();
            response.send("image/jpeg", bout.toByteArray());
            return;
        } catch (Exception e) {
            response.code(500);
            response.send(e.toString());
            return;
        }
    }
    Log.i(Main.TAG, "screenshot authentication failed");
    response.code(401);
    response.send("Not Authorized.");
}
 
开发者ID:lifengsofts,项目名称:AndroidRemoteScreen,代码行数:21,代码来源:AnonymousClass5.java

示例3: onRequest

import com.koushikdutta.async.http.server.AsyncHttpServerResponse; //导入方法依赖的package包/类
public void onRequest(AsyncHttpServerRequest asyncHttpServerRequest, AsyncHttpServerResponse httpServerResponse) {
    if (sCurrentVideo != null && sCurrentVideo.exists()) {
        mFileType.setHeaders(httpServerResponse);
        httpServerResponse.sendFile(sCurrentVideo);
    } else {
        httpServerResponse.send("Not found");
        httpServerResponse.code(404);
    }

    Timber.i(httpServerResponse.toString());
}
 
开发者ID:PTCE,项目名称:popcorn-android,代码行数:12,代码来源:BeamServer.java

示例4: shouldPass

import com.koushikdutta.async.http.server.AsyncHttpServerResponse; //导入方法依赖的package包/类
private boolean shouldPass(final AsyncHttpServerRequest req, final AsyncHttpServerResponse res) {
    if (isStopped) {
        res.code(404);
        res.end();
        return false;
    }
    if (!isAuthenticated(req)) {
        res.getHeaders().add("WWW-Authenticate", "Basic realm=\"DeviceControl\"");
        res.code(401);
        res.end();
        return false;
    }
    return true;
}
 
开发者ID:amartinz,项目名称:DeviceControl,代码行数:15,代码来源:ServerWrapper.java


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