4267a229创建于 2024年8月2日历史提交
/*
    Copyright (c) [2023] [squallzhao]
    fountain is licensed under APACHE LICENSE, VERSION 2.0.
    You can use this software according to the terms and conditions of the APACHE LICENSE, VERSION 2.0.
    You may obtain a copy of APACHE LICENSE, VERSION 2.0 at: https://www.apache.org/licenses/LICENSE-2.0
*/
package microservice.web.http11

public class Http11Res{
    public var headers = Headers()
    public var code = Http11Protocol.SC_OK
    public var body = ""

    public func toHttp(): String{
        if (body.size>0){
            headers.put(HttpCommon.CONTENT_LENGTH,body.size.toString());
        }
        headers.put(HttpCommon.CONNECTION,"keep-alive")
        return "HTTP/1.1 "+code.toString()+" OK\r\n"+headers.toHttp()+"\r\n"+body;
    }
}