dreamhead / moco

Easy Setup Stub Server
MIT License
4.37k stars 1.08k forks source link

Response header 同时配置content-type & content-length, 响应卡住 #345

Open iamJunPan opened 8 months ago

iamJunPan commented 8 months ago

复现场景 (两种设置response方式均会卡住,没有响应值)

    @Test
    public void testHeaders() throws Exception {
        HttpServer server = httpServer(12306);
        server.response(header("content-type", "application/json"), header("content-length", "100"));

        //server.response(header("content-type", "application/json")).response(header("content-length", "100"));
        running(server, () -> {
            Request request = Request.Post("http://localhost:12306/");
            HttpResponse response = request.execute().returnResponse();
            System.out.print("response:" + response + "\n");
            List<String> contentTypeValues = HttpResponseUtils.getHeader(response, "content-type");
            List<String> contentLengthValues = HttpResponseUtils.getHeader(response, "content-length");
            System.out.print(contentLengthValues);
            System.out.print(contentTypeValues);
            assertEquals("application/json", contentTypeValues.get(0));
            assertEquals("100", contentTypeValues.get(0));
        });
    }