Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 45 for WriteTo (0.2 sec)

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

        assertOnFileDescriptor(content = "Hello") { fd ->
          val requestBody = fd.toRequestBody()
    
          val buffer = Buffer()
          requestBody.writeTo(buffer)
          assertThat(buffer.readUtf8()).isEqualTo("Hello")
    
          assertThrows(IOException::class.java) {
            requestBody.writeTo(Buffer())
          }
        }
      }
    
      @Test
      fun testFileDescriptorAfterClose() {
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 3.6K bytes
    - Viewed (1)
  2. okhttp/src/test/java/okhttp3/ServerTruncatesRequestTest.kt

          )
    
        call.execute().use { response ->
          assertThat(response.body.string()).isEqualTo("abc")
          val requestBodyOut = requestBody.takeSink()
          assertFailsWith<IOException> {
            SlowRequestBody.writeTo(requestBodyOut)
          }
          assertFailsWith<IOException> {
            requestBodyOut.close()
          }
        }
    
        // Confirm that the connection pool was not corrupted by making another call.
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 9.5K bytes
    - Viewed (0)
  3. samples/guide/src/main/java/okhttp3/recipes/PostStreaming.java

      public void run() throws Exception {
        RequestBody requestBody = new RequestBody() {
          @Override public MediaType contentType() {
            return MEDIA_TYPE_MARKDOWN;
          }
    
          @Override public void writeTo(BufferedSink sink) throws IOException {
            sink.writeUtf8("Numbers\n");
            sink.writeUtf8("-------\n");
            for (int i = 2; i <= 997; i++) {
              sink.writeUtf8(String.format(" * %s = %s\n", i, factor(i)));
    Java
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Fri Jul 06 03:18:15 GMT 2018
    - 2.1K bytes
    - Viewed (0)
  4. okhttp/src/test/java/okhttp3/URLConnectionTest.kt

              url = server.url("/"),
              body =
                object : ForwardingRequestBody(transferKind.newRequestBody("def")) {
                  override fun writeTo(sink: BufferedSink) {
                    sinkReference.set(sink)
                    super.writeTo(sink)
                  }
                },
            ),
          )
        assertThat(readAscii(response.body.byteStream(), Int.MAX_VALUE))
          .isEqualTo("abc")
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sat Jan 20 10:30:28 GMT 2024
    - 131.7K bytes
    - Viewed (0)
  5. okhttp/src/test/java/okhttp3/MultipartBodyTest.kt

        val buffer = Buffer()
        body.writeTo(buffer)
        assertThat(buffer.readUtf8()).isEqualTo(expected)
      }
    
      @Test
      fun streamingPartHasNoLength() {
        class StreamingBody(private val body: String) : RequestBody() {
          override fun contentType(): MediaType? {
            return null
          }
    
          @Throws(IOException::class)
          override fun writeTo(sink: BufferedSink) {
            sink.writeUtf8(body)
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 10.4K bytes
    - Viewed (0)
  6. okhttp/src/main/kotlin/okhttp3/RequestBody.kt

      /**
       * Returns the number of bytes that will be written to sink in a call to [writeTo],
       * or -1 if that count is unknown.
       */
      @Throws(IOException::class)
      open fun contentLength(): Long = commonContentLength()
    
      /** Writes the content of this request to [sink]. */
      @Throws(IOException::class)
      abstract fun writeTo(sink: BufferedSink)
    
      /**
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Thu Jan 25 14:41:37 GMT 2024
    - 9.6K bytes
    - Viewed (0)
  7. okhttp/src/test/java/okhttp3/FormBodyTest.kt

        val out = Buffer()
        body.writeTo(out)
        assertThat(out.readUtf8()).isEqualTo(expected)
      }
    
      @Test
      fun encodedPair() {
        val body =
          FormBody.Builder()
            .add("sim", "ple")
            .build()
        val expected = "sim=ple"
        assertThat(body.contentLength()).isEqualTo(expected.length.toLong())
        val buffer = Buffer()
        body.writeTo(buffer)
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 7.8K bytes
    - Viewed (0)
  8. okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt

            } else if (requestBody.isOneShot()) {
              logger.log("--> END ${request.method} (one-shot body omitted)")
            } else {
              var buffer = Buffer()
              requestBody.writeTo(buffer)
    
              var gzippedLength: Long? = null
              if ("gzip".equals(headers["Content-Encoding"], ignoreCase = true)) {
                gzippedLength = buffer.size
    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)
  9. okhttp-testing-support/src/main/kotlin/okhttp3/UppercaseRequestInterceptor.kt

        val uppercaseBody: RequestBody =
          object : ForwardingRequestBody(request.body) {
            @Throws(IOException::class)
            override fun writeTo(sink: BufferedSink) {
              delegate().writeTo(uppercaseSink(sink).buffer())
            }
          }
        return request.newBuilder()
          .method(request.method, uppercaseBody)
          .build()
      }
    
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  10. okhttp/src/main/kotlin/okhttp3/internal/http/CallServerInterceptor.kt

                requestBody.writeTo(bufferedRequestBody)
              } else {
                // Write the request body if the "Expect: 100-continue" expectation was met.
                val bufferedRequestBody = exchange.createRequestBody(request, false).buffer()
                requestBody.writeTo(bufferedRequestBody)
                bufferedRequestBody.close()
              }
            } else {
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 6.3K bytes
    - Viewed (1)
Back to top