Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 18 for throttleBody (0.08 sec)

  1. okhttp/src/jvmTest/kotlin/okhttp3/internal/http/ThreadInterruptTest.kt

      @Test
      fun interruptReadingResponseBody() {
        val responseBodySize = 8 * 1024 * 1024 // 8 MiB.
        server.enqueue(
          MockResponse()
            .setBody(Buffer().write(ByteArray(responseBodySize)))
            .throttleBody((64 * 1024).toLong(), 125, TimeUnit.MILLISECONDS),
        ) // 500 Kbps
        server.start()
        val call =
          client.newCall(
            Request
              .Builder()
              .url(server.url("/"))
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Sat Aug 30 11:30:11 UTC 2025
    - 6.1K bytes
    - Viewed (0)
  2. mockwebserver-deprecated/src/test/java/okhttp3/mockwebserver/KotlinSourceModernTest.kt

        mockResponse.socketPolicy = SocketPolicy.KEEP_OPEN
        var http2ErrorCode: Int = mockResponse.http2ErrorCode
        mockResponse.http2ErrorCode = 0
        mockResponse = mockResponse.throttleBody(0L, 0L, TimeUnit.SECONDS)
        var throttleBytesPerPeriod: Long = mockResponse.throttleBytesPerPeriod
        throttleBytesPerPeriod = mockResponse.throttleBytesPerPeriod
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Mon Jan 08 01:13:22 UTC 2024
    - 7.3K bytes
    - Viewed (0)
  3. okhttp/src/jvmTest/kotlin/okhttp3/internal/http/CancelTest.kt

        val responseBodySize = 8 * 1024 * 1024 // 8 MiB.
        server.enqueue(
          MockResponse
            .Builder()
            .body(
              Buffer()
                .write(ByteArray(responseBodySize)),
            ).throttleBody(64 * 1024, 125, MILLISECONDS) // 500 Kbps
            .build(),
        )
        val call = client.newCall(Request(server.url("/")))
        val response = call.execute()
        cancelLater(call, 500)
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Wed Mar 19 19:25:20 UTC 2025
    - 9.8K bytes
    - Viewed (0)
  4. mockwebserver-deprecated/src/main/kotlin/okhttp3/mockwebserver/MockResponse.kt

      )
      fun getHttp2ErrorCode(): Int = http2ErrorCode
    
      fun setHttp2ErrorCode(http2ErrorCode: Int) =
        apply {
          this.http2ErrorCode = http2ErrorCode
        }
    
      fun throttleBody(
        bytesPerPeriod: Long,
        period: Long,
        unit: TimeUnit,
      ) = apply {
        throttleBytesPerPeriod = bytesPerPeriod
        throttlePeriodAmount = period
        throttlePeriodUnit = unit
      }
    
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Sat May 10 11:15:14 UTC 2025
    - 7.1K bytes
    - Viewed (0)
  5. okhttp/src/jvmTest/kotlin/okhttp3/InterceptorTest.kt

            .addInterceptor(interceptor1)
            .addInterceptor(interceptor2)
            .build()
        server.enqueue(
          MockResponse
            .Builder()
            .body("abc")
            .throttleBody(1, 1, TimeUnit.SECONDS)
            .build(),
        )
        val request1 =
          Request
            .Builder()
            .url(server.url("/"))
            .build()
        val call = client.newCall(request1)
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Fri Jun 20 11:46:46 UTC 2025
    - 28.2K bytes
    - Viewed (0)
  6. mockwebserver/README.md

    testing timeouts and interactive testing.
    
    ### Java
    ```java
    MockResponse response = new MockResponse.Builder()
        .throttleBody(1024, 1, TimeUnit.SECONDS)
        .build();
    ```
    
    ### Kotlin
    ```kotlin
    val response = MockResponse.Builder()
      .throttleBody(1024, 1, TimeUnit.SECONDS)
      .build()
    ```
    
    #### RecordedRequest
    
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Sat Jul 19 13:40:52 UTC 2025
    - 8.1K bytes
    - Viewed (0)
  7. mockwebserver-deprecated/src/main/kotlin/okhttp3/mockwebserver/DeprecationBridge.kt

        SocketPolicy.NO_RESPONSE -> result.onResponseStart(SocketEffect.Stall)
        SocketPolicy.RESET_STREAM_AT_START -> result.onRequestStart(CloseStream(http2ErrorCode))
      }
    
      result.throttleBody(throttleBytesPerPeriod, getThrottlePeriod(MILLISECONDS), MILLISECONDS)
      result.bodyDelay(getBodyDelay(MILLISECONDS), MILLISECONDS)
      result.headersDelay(getHeadersDelay(MILLISECONDS), MILLISECONDS)
      return result.build()
    }
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Thu Jul 03 13:16:34 UTC 2025
    - 4.1K bytes
    - Viewed (0)
  8. okhttp/src/jvmTest/kotlin/okhttp3/EventListenerTest.kt

        }
      }
    
      @Test
      fun failedDribbledCallEventSequence() {
        server.enqueue(
          MockResponse
            .Builder()
            .body("0123456789")
            .throttleBody(2, 100, TimeUnit.MILLISECONDS)
            .onResponseBody(CloseSocket())
            .build(),
        )
        client =
          client
            .newBuilder()
            .protocols(listOf<Protocol>(Protocol.HTTP_1_1))
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Fri Jun 20 11:46:46 UTC 2025
    - 60.4K bytes
    - Viewed (0)
  9. mockwebserver/src/main/kotlin/mockwebserver3/MockResponse.kt

        /**
         * Throttles the request reader and response writer to sleep for the given period after each
         * series of [bytesPerPeriod] bytes are transferred. Use this to simulate network behavior.
         */
        public fun throttleBody(
          bytesPerPeriod: Long,
          period: Long,
          unit: TimeUnit,
        ): Builder =
          apply {
            throttleBytesPerPeriod = bytesPerPeriod
            throttlePeriodNanos = unit.toNanos(period)
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Fri Jun 20 11:46:46 UTC 2025
    - 17.8K bytes
    - Viewed (0)
  10. mockwebserver-deprecated/src/test/java/okhttp3/mockwebserver/MockWebServerTest.kt

       * should yield one sleep for a total delay of 500ms.
       */
      @Test
      fun throttleRequest() {
        assumeNotWindows()
        server.enqueue(
          MockResponse()
            .throttleBody(3, 500, TimeUnit.MILLISECONDS),
        )
        val startNanos = System.nanoTime()
        val connection = server.url("/").toUrl().openConnection()
        connection.setDoOutput(true)
    Registered: Fri Sep 05 11:42:10 UTC 2025
    - Last Modified: Thu Jul 03 13:16:34 UTC 2025
    - 22.3K bytes
    - Viewed (0)
Back to top