Skip to content

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

Description

@iamJunPan

复现场景 (两种设置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));
        });
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions