jodd.http.HttpResponse.statusPhrase()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中jodd.http.HttpResponse.statusPhrase()方法的一些代码示例,展示了HttpResponse.statusPhrase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.statusPhrase()方法的具体详情如下:
包路径:jodd.http.HttpResponse
类名称:HttpResponse
方法名:statusPhrase

HttpResponse.statusPhrase介绍

[英]Returns response status phrase.
[中]返回响应状态短语。

代码示例

代码示例来源:origin: oblac/jodd

httpResponse.statusPhrase(line.substring(ndx2).trim());

代码示例来源:origin: oblac/jodd

@Test
void testUploadWithUploadable() throws IOException {
  HttpResponse response = HttpRequest
      .post("http://localhost:8173/echo2")
      .multipart(true)
      .form("id", "12")
      .form("file", new ByteArrayUploadable(
        "upload тест".getBytes(StringPool.UTF_8), "d ст", MimeTypes.MIME_TEXT_PLAIN))
      .send();
  assertEquals(200, response.statusCode());
  assertEquals("OK", response.statusPhrase());
  assertEquals("12", Data.ref.params.get("id"));
  assertEquals("upload тест", Data.ref.parts.get("file"));
  assertEquals("d ст", Data.ref.fileNames.get("file"));
}

代码示例来源:origin: oblac/jodd

@Test
void testEcho() throws IOException {
  EchoTestServer echoTestServer = new EchoTestServer();
  HttpResponse response = HttpRequest.get("http://localhost:8081/hello?id=12").send();
  assertEquals(200, response.statusCode());
  assertEquals("OK", response.statusPhrase());
  assertEquals("GET", echoTestServer.method);
  assertEquals("/hello", echoTestServer.uri);
  assertEquals(1, echoTestServer.params.size());
  assertEquals("12", echoTestServer.params.get("id"));
  assertEquals("GET /hello", response.body());
  echoTestServer.stop();
}

代码示例来源:origin: oblac/jodd

@Test
void testUploadWithUploadable() throws IOException {
  EchoTestServer echoTestServer = new EchoTestServer();
  HttpResponse response = HttpRequest
      .post("http://localhost:8081/hello")
      .multipart(true)
      .form("id", "12")
      .form("file", new ByteArrayUploadable(
        "upload тест".getBytes(StringPool.UTF_8), "d ст", MimeTypes.MIME_TEXT_PLAIN))
      .send();
  assertEquals(200, response.statusCode());
  assertEquals("OK", response.statusPhrase());
  assertEquals("POST", echoTestServer.method);
  assertEquals("12", echoTestServer.params.get("id"));
  File uploadedFile = new File(echoTestServer.files.get("file").toString());
  assertNotNull(uploadedFile);
  assertEquals("upload тест", FileUtil.readString(uploadedFile));
  assertEquals("POST /hello", response.body());
  echoTestServer.stop();
}

代码示例来源:origin: oblac/jodd

@Test
void testUpload() throws IOException {
  EchoTestServer echoTestServer = new EchoTestServer();
  File file = FileUtil.createTempFile();
  file.deleteOnExit();
  FileUtil.writeString(file, "upload тест");
  assertEquals("upload тест", FileUtil.readString(file));
  HttpResponse response = HttpRequest
      .post("http://localhost:8081/hello")
      .form("id", "12")
      .form("file", file)
      .send();
  assertEquals(200, response.statusCode());
  assertEquals("OK", response.statusPhrase());
  assertEquals("POST", echoTestServer.method);
  assertEquals("12", echoTestServer.params.get("id"));
  File uploadedFile = new File(echoTestServer.files.get("file").toString());
  assertNotNull(uploadedFile);
  assertEquals("upload тест", FileUtil.readString(uploadedFile));
  assertEquals("POST /hello", response.body());
  echoTestServer.stop();
  file.delete();
}

代码示例来源:origin: oblac/jodd

@Test
void testUploadWithMonitor() throws IOException {
  EchoTestServer echoTestServer = new EchoTestServer();
  File file = FileUtil.createTempFile();
  file.deleteOnExit();
  FileUtil.writeString(file, StringUtil.repeat('A', 1024));
  final StringBuilder sb = new StringBuilder();
  HttpResponse response = HttpRequest
      .post("http://localhost:8081/hello")
      .form("id", "12")
      .form("file", file)
      .monitor(new HttpProgressListener() {
        @Override
        public void transferred(int len) {
          sb.append(":" + len);
        }
      })
      .send();
  assertEquals(200, response.statusCode());
  assertEquals("OK", response.statusPhrase());
  echoTestServer.stop();
  file.delete();
  assertEquals(":0:512:1024:148", StringUtil.substring(sb.toString(), 0, -1));
}

代码示例来源:origin: oblac/jodd

httpResponse.assignHttpRequest(httpRequest);
httpResponse.statusCode(503);
httpResponse.statusPhrase("Service unavailable. " + ExceptionUtil.message(httpException));

代码示例来源:origin: org.jodd/jodd-http

httpResponse.statusPhrase(line.substring(ndx2).trim());

代码示例来源:origin: com.liferay.launchpad/api-client

clientResponse.status(response.statusCode(), response.statusPhrase());
clientResponse.body(response.bodyText());

代码示例来源:origin: com.liferay.launchpad/api-transport-jodd

clientResponse.statusMessage(response.statusPhrase());
clientResponse.body(response.body());

代码示例来源:origin: org.jodd/jodd-http

httpResponse.assignHttpRequest(httpRequest);
httpResponse.statusCode(503);
httpResponse.statusPhrase("Service unavailable. " + ExceptionUtil.message(httpException));

相关文章