Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 19 for ResponseBody (0.2 sec)

  1. okhttp/src/main/kotlin/okhttp3/ResponseBody.kt

     *
     * ```java
     * Call call = client.newCall(request);
     * call.enqueue(new Callback() {
     *   public void onResponse(Call call, Response response) throws IOException {
     *     try (ResponseBody responseBody = response.body()) {
     *     ... // Use the response.
     *     }
     *   }
     *
     *   public void onFailure(Call call, IOException e) {
     *   ... // Handle the failure.
     *   }
     * });
     * ```
     *
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 10.7K bytes
    - Viewed (0)
  2. okhttp/src/test/java/okhttp3/ResponseBodyJvmTest.kt

        assertThat(body.string()).isEqualTo("hello")
      }
    
      @Test
      fun stringClosesUnderlyingSource() {
        val closed = AtomicBoolean()
        val body: ResponseBody =
          object : ResponseBody() {
            override fun contentType(): MediaType? {
              return null
            }
    
            override fun contentLength(): Long {
              return 5
            }
    
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 13K bytes
    - Viewed (0)
  3. okhttp/src/test/java/okhttp3/DuplexTest.kt

          val responseBody = response.body.source()
          assertThat(responseBody.readUtf8Line())
            .isEqualTo("response A")
          assertThat(responseBody.readUtf8Line())
            .isEqualTo("response B")
          requestBody.writeUtf8("request C\n")
          requestBody.close()
          assertThat(responseBody.readUtf8Line()).isNull()
        }
        body.awaitSuccess()
      }
    
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Jan 20 10:30:28 GMT 2024
    - 23.9K bytes
    - Viewed (0)
  4. okhttp/src/test/java/okhttp3/internal/http/CancelTest.kt

        val response = call.execute()
        cancelLater(call, 500)
        val responseBody = response.body.byteStream()
        val buffer = ByteArray(1024)
        assertFailsWith<IOException> {
          while (responseBody.read(buffer) != -1) {
          }
        }.also { expected ->
          assertEquals(cancelMode == INTERRUPT, Thread.interrupted())
        }
        responseBody.close()
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Jan 20 10:30:28 GMT 2024
    - 9.9K bytes
    - Viewed (0)
  5. okhttp/src/main/kotlin/okhttp3/Response.kt

       * from [Call.execute]. Response bodies must be [closed][ResponseBody] and may
       * be consumed only once.
       *
       * This always returns null on responses returned from [cacheResponse], [networkResponse],
       * and [priorResponse].
       */
      @get:JvmName("body") val body: ResponseBody,
      /**
       * Returns the raw response received from the network. Will be null if this response didn't use
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Tue Jan 23 14:31:42 GMT 2024
    - 15.5K bytes
    - Viewed (0)
  6. okhttp/src/test/java/okhttp3/KotlinSourceModernTest.kt

        val bytes = responseBody.bytes()
        val charStream = responseBody.charStream()
        val string = responseBody.string()
        responseBody.close()
        responseBody = "".toResponseBody("".toMediaType())
        responseBody = "".toResponseBody(null)
        responseBody = ByteString.EMPTY.toResponseBody("".toMediaType())
        responseBody = ByteString.EMPTY.toResponseBody(null)
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Apr 01 14:21:25 GMT 2024
    - 46.5K bytes
    - Viewed (4)
  7. okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt

            logger.log("<-- HTTP FAILED: $e")
            throw e
          }
    
          val tookMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs)
    
          val responseBody = response.body!!
          val contentLength = responseBody.contentLength()
          val bodySize = if (contentLength != -1L) "$contentLength-byte" else "unknown-length"
          logger.log(
            buildString {
              append("<-- ${response.code}")
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Apr 06 09:14:38 GMT 2024
    - 11.2K bytes
    - Viewed (1)
  8. docs/changelogs/upgrading_to_okhttp_4.md

    | RequestBody.create(String)          | String.toRequestBody()          |
    | ResponseBody.create(BufferedSource) | BufferedSource.asResponseBody() |
    | ResponseBody.create(ByteArray)      | ByteArray.toResponseBody()      |
    | ResponseBody.create(ByteString)     | ByteString.toResponseBody()     |
    | ResponseBody.create(String)         | String.toResponseBody()         |
    
    
    SAM Conversions
    ---------------
    
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sun Feb 06 16:58:16 GMT 2022
    - 10.9K bytes
    - Viewed (0)
  9. okhttp/src/test/java/okhttp3/MultipartReaderTest.kt

          |
          |abcd
          |--simple boundary--
          """.trimMargin()
            .replace("\n", "\r\n")
    
        val responseBody =
          multipart.toResponseBody(
            "application/multipart; boundary=\"simple boundary\"".toMediaType(),
          )
    
        val parts = MultipartReader(responseBody)
        assertThat(parts.boundary).isEqualTo("simple boundary")
    
        val part = parts.nextPart()!!
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 13.8K bytes
    - Viewed (0)
  10. okhttp-logging-interceptor/src/test/java/okhttp3/logging/HttpLoggingInterceptorTest.kt

              .post("Uncompressed".toRequestBody().gzip())
              .build(),
          ).execute()
        val responseBody = response.body
        assertThat(responseBody.string(), "Expected response body to be valid")
          .isEqualTo("Uncompressed")
        responseBody.close()
        networkLogs
          .assertLogEqual("--> POST $url http/1.1")
          .assertLogEqual("Content-Encoding: gzip")
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Apr 06 09:14:38 GMT 2024
    - 37.6K bytes
    - Viewed (0)
Back to top