Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 97 for body (0.14 sec)

  1. okhttp/src/test/java/okhttp3/ServerTruncatesRequestTest.kt

        server.enqueue(
          MockResponse(
            body = "abc",
            socketPolicy = DoNotReadRequestBody(ErrorCode.NO_ERROR.httpCode),
          ),
        )
    
        val call =
          client.newCall(
            Request(
              url = server.url("/"),
              body = SlowRequestBody,
            ),
          )
    
        call.execute().use { response ->
          assertThat(response.body.string()).isEqualTo("abc")
        }
    
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 9.5K bytes
    - Viewed (0)
  2. okhttp/src/main/kotlin/okhttp3/Callback.kt

       * proceed to read the response body with [Response.body]. The response is still live until its
       * response body is [closed][ResponseBody]. The recipient of the callback may consume the response
       * body on another thread.
       *
       * Note that transport-layer success (receiving a HTTP response code, headers and body) does not
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.6K bytes
    - Viewed (0)
  3. okhttp/src/test/java/okhttp3/internal/http/ExternalHttp2Example.kt

        try {
          println(response.code)
          println("PROTOCOL ${response.protocol}")
          var line: String?
          while (response.body.source().readUtf8Line().also { line = it } != null) {
            println(line)
          }
        } finally {
          response.body.close()
        }
        client.connectionPool.evictAll()
      }
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.4K bytes
    - Viewed (0)
  4. docs/features/events.md

    try (Response response = client.newCall(request).execute()) {
      // Consume and discard the response body.
      response.body().source().readByteString();
    }
    
    System.out.println("REQUEST 2 (pooled connection)");
    try (Response response = client.newCall(request).execute()) {
      // Consume and discard the response body.
      response.body().source().readByteString();
    }
    ```
    
    And the listener prints the corresponding events:
    
    ```
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sun Feb 06 02:19:09 GMT 2022
    - 7.7K bytes
    - Viewed (0)
  5. mockwebserver/README.md

    ```
    
    Your unit tests might move the `server` into a field so you can shut it down
    from your test's `tearDown()`.
    
    ### API
    
    #### MockResponse
    
    Mock responses default to an empty response body and a `200` status code.
    You can set a custom body with a string, input stream or byte array. Also
    add headers with a fluent builder API.
    
    ```java
    MockResponse response = new MockResponse()
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sun Dec 17 15:34:10 GMT 2023
    - 5K bytes
    - Viewed (1)
  6. samples/compare/src/test/kotlin/okhttp3/compare/JavaHttpClientTest.kt

          MockResponse.Builder()
            .body("hello, Java HTTP Client")
            .build(),
        )
    
        val request =
          HttpRequest.newBuilder(server.url("/").toUri())
            .header("Accept", "text/plain")
            .build()
    
        val response = httpClient.send(request, BodyHandlers.ofString())
        assertThat(response.statusCode()).isEqualTo(200)
        assertThat(response.body()).isEqualTo("hello, Java HTTP Client")
    
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 2.7K bytes
    - Viewed (0)
  7. samples/guide/src/main/java/okhttp3/recipes/kt/Authenticate.kt

            .build()
    
        client.newCall(request).execute().use { response ->
          if (!response.isSuccessful) throw IOException("Unexpected code $response")
    
          println(response.body.string())
        }
      }
    }
    
    fun main() {
      Authenticate().run()
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  8. container-tests/src/test/java/okhttp3/containers/SocksProxyTest.kt

              .build()
    
          val response =
            client.newCall(
              Request("http://mockserver:1080/person?name=peter".toHttpUrl()),
            ).execute()
    
          assertThat(response.body.string()).contains("Peter the person")
        }
      }
    
      companion object {
        val SOCKS5_PROXY: DockerImageName =
          DockerImageName
            .parse("serjs/go-socks5-proxy")
            .withTag("v0.0.3")
      }
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Fri Apr 05 03:30:42 GMT 2024
    - 2.6K bytes
    - Viewed (0)
  9. samples/compare/src/test/kotlin/okhttp3/compare/ApacheHttpClientTest.kt

      @AfterEach fun tearDown() {
        httpClient.close()
      }
    
      @Test fun get(server: MockWebServer) {
        server.enqueue(
          MockResponse.Builder()
            .body("hello, Apache HttpClient 5.x")
            .build(),
        )
    
        val request = HttpGet(server.url("/").toUri())
        request.addHeader("Accept", "text/plain")
    
        httpClient.execute(request).use { response ->
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 2.1K bytes
    - Viewed (0)
  10. regression-test/src/androidTest/java/okhttp/regression/compare/ApacheHttpClientHttp2Test.kt

          val response = client.execute(request, LoggingCallback).get()
    
          println("Protocol ${response.version}")
          println("Response ${response.code}")
          println("${response.body.bodyText.substring(0, 20)}...")
    
          Assert.assertEquals(ProtocolVersion("HTTP", 2, 0), response.version)
        }
      }
    }
    
    object LoggingCallback : FutureCallback<SimpleHttpResponse> {
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 2.6K bytes
    - Viewed (0)
Back to top