Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 110 for Content (0.16 sec)

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

      override fun contentType(): MediaType = CONTENT_TYPE
    
      override fun contentLength(): Long = writeOrCountBytes(null, true)
    
      @Throws(IOException::class)
      override fun writeTo(sink: BufferedSink) {
        writeOrCountBytes(sink, false)
      }
    
      /**
       * Either writes this request to [sink] or measures its content length. We have one method
       * do double-duty to make sure the counting and content are consistent, particularly when it comes
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Tue Jan 09 12:33:05 GMT 2024
    - 4.3K bytes
    - Viewed (0)
  2. okhttp-android/src/androidTest/kotlin/okhttp3/android/AndroidAsyncDnsTest.kt

        assertThat(allAddresses).isEmpty()
      }
    
      @Test
      fun testRequestOnNetwork() {
        assumeNetwork()
    
        val context = InstrumentationRegistry.getInstrumentation().context
        val connectivityManager =
          context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
    
        val network =
          connectivityManager.activeNetwork ?: throw AssumptionViolatedException("No active network")
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 5.7K bytes
    - Viewed (0)
  3. okhttp/src/test/java/okhttp3/internal/http2/HttpOverHttp2Test.kt

            .status("HTTP/1.1 204")
            .removeHeader("Content-Length")
            .build()
        server.enqueue(responseWithoutBody)
        val call = client.newCall(Request(server.url("/foo")))
        val response = call.execute()
    
        // Body contains nothing.
        assertThat(response.body.bytes().size).isEqualTo(0)
        assertThat(response.body.contentLength()).isEqualTo(0)
    
        // Content-Length header doesn't exist in a 204 response.
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Thu Apr 11 22:09:35 GMT 2024
    - 75.3K bytes
    - Viewed (0)
  4. okhttp/src/main/kotlin/okhttp3/internal/-UtilJvm.kt

      currentThread.name = name
      try {
        block()
      } finally {
        currentThread.name = oldName
      }
    }
    
    /** Returns the Content-Length as reported by the response headers. */
    internal fun Response.headersContentLength(): Long {
      return headers["Content-Length"]?.toLongOrDefault(-1L) ?: -1L
    }
    
    /** Returns an immutable copy of this. */
    internal fun <T> List<T>.toImmutableList(): List<T> {
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Tue Jan 09 12:33:05 GMT 2024
    - 10.5K bytes
    - Viewed (0)
  5. okhttp/src/main/kotlin/okhttp3/Request.kt

        /**
         * Adds a header with [name] and [value]. Prefer this method for multiply-valued
         * headers like "Cookie".
         *
         * Note that for some headers including `Content-Length` and `Content-Encoding`,
         * OkHttp may replace [value] with a header derived from the request body.
         */
        open fun addHeader(
          name: String,
          value: String,
        ) = commonAddHeader(name, value)
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sat Apr 06 04:17:44 GMT 2024
    - 10.5K bytes
    - Viewed (0)
  6. okhttp/src/test/java/okhttp3/ResponseJvmTest.kt

       * Returns a new response body that refuses to be read once it has been closed. This is true of
       * most [BufferedSource] instances, but not of [Buffer].
       */
      private fun responseBody(content: String): ResponseBody {
        val data = Buffer().writeUtf8(content)
        val source: Source =
          object : Source {
            var closed = false
    
            override fun close() {
              closed = true
            }
    
            override fun read(
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 3.1K bytes
    - Viewed (0)
  7. mockwebserver-deprecated/src/main/kotlin/okhttp3/mockwebserver/MockResponse.kt

      fun setBody(body: Buffer) =
        apply {
          setHeader("Content-Length", body.size)
          this.body = body.clone() // Defensive copy.
        }
    
      fun setBody(body: String): MockResponse = setBody(Buffer().writeUtf8(body))
    
      fun setChunkedBody(
        body: Buffer,
        maxChunkSize: Int,
      ) = apply {
        removeHeader("Content-Length")
        headersBuilder.add(CHUNKED_BODY_HEADER)
    
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 7.2K bytes
    - Viewed (0)
  8. okhttp/src/test/java/okhttp3/CacheTest.kt

        assertThat(cache.hitCount()).isEqualTo(0)
      }
    
      private fun corruptCertificate(cacheEntry: Path) {
        var content = fileSystem.source(cacheEntry).buffer().readUtf8()
        content = content.replace("MII", "!!!")
        fileSystem.sink(cacheEntry).buffer().writeUtf8(content).close()
      }
    
      @Test
      fun responseCachingAndRedirects() {
        server.enqueue(
          MockResponse.Builder()
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Wed Apr 10 19:46:48 GMT 2024
    - 108.6K bytes
    - Viewed (0)
  9. okhttp/src/main/kotlin/okhttp3/internal/http/CallServerInterceptor.kt

          ) {
            exchange.noNewExchangesOnConnection()
          }
          if ((code == 204 || code == 205) && response.body.contentLength() > 0L) {
            throw ProtocolException(
              "HTTP $code had non-zero Content-Length: ${response.body.contentLength()}",
            )
          }
          return response
        } catch (e: IOException) {
          if (sendRequestException != null) {
            sendRequestException.addSuppressed(e)
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 6.3K bytes
    - Viewed (1)
  10. samples/guide/src/main/java/okhttp3/recipes/kt/ParseResponseWithMoshi.kt

          for ((key, value) in gist!!.files!!) {
            println(key)
            println(value.content)
          }
        }
      }
    
      @JsonClass(generateAdapter = true)
      data class Gist(var files: Map<String, GistFile>?)
    
      @JsonClass(generateAdapter = true)
      data class GistFile(var content: String?)
    }
    
    fun main() {
      ParseResponseWithMoshi().run()
    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 (1)
Back to top