Search Options

Results per page
Sort
Preferred Languages
Advance

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

  1. okhttp/src/test/java/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)
    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)
  2. okhttp/src/test/java/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("/"))
              .build(),
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 4.6K bytes
    - Viewed (0)
  3. mockwebserver/README.md

        .addHeader("Cache-Control", "no-cache")
        .setBody("{}");
    ```
    
    MockResponse can be used to simulate a slow network. This is useful for
    testing timeouts and interactive testing.
    
    ```java
    response.throttleBody(1024, 1, TimeUnit.SECONDS);
    ```
    
    
    #### RecordedRequest
    
    Verify requests by their method, path, HTTP version, body, and headers.
    
    ```java
    RecordedRequest request = server.takeRequest();
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sun Dec 17 15:34:10 GMT 2023
    - 5K bytes
    - Viewed (1)
  4. mockwebserver-deprecated/src/main/kotlin/okhttp3/mockwebserver/DeprecationBridge.kt

            result.add100Continue()
            KeepOpen
          }
          SocketPolicy.UPGRADE_TO_SSL_AT_END -> {
            result.inTunnel()
            KeepOpen
          }
          else -> wrapSocketPolicy()
        }
      result.throttleBody(throttleBytesPerPeriod, getThrottlePeriod(MILLISECONDS), MILLISECONDS)
      result.bodyDelay(getBodyDelay(MILLISECONDS), MILLISECONDS)
      result.headersDelay(getHeadersDelay(MILLISECONDS), MILLISECONDS)
      return result.build()
    }
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 4.6K bytes
    - Viewed (0)
  5. 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
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 7.3K bytes
    - Viewed (1)
  6. 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)
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 21.9K bytes
    - Viewed (0)
  7. mockwebserver/src/test/java/mockwebserver3/MockWebServerTest.kt

       * should yield one sleep for a total delay of 500ms.
       */
      @Test
      fun throttleRequest() {
        assumeNotWindows()
        server.enqueue(
          MockResponse.Builder()
            .throttleBody(3, 500, TimeUnit.MILLISECONDS)
            .build(),
        )
        val startNanos = System.nanoTime()
        val connection = server.url("/").toUrl().openConnection()
        connection.doOutput = true
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 23.5K bytes
    - Viewed (0)
  8. 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
      }
    
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 7.2K bytes
    - Viewed (0)
  9. okhttp/src/test/java/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)
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Sun Jan 14 10:20:09 GMT 2024
    - 27.8K bytes
    - Viewed (0)
  10. 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.
         */
        fun throttleBody(
          bytesPerPeriod: Long,
          period: Long,
          unit: TimeUnit,
        ) = apply {
          throttleBytesPerPeriod = bytesPerPeriod
          throttlePeriodNanos = unit.toNanos(period)
        }
    
        /**
    Plain Text
    - Registered: Fri Apr 26 11:42:10 GMT 2024
    - Last Modified: Tue Jan 23 14:31:42 GMT 2024
    - 13.3K bytes
    - Viewed (1)
Back to top