Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 27 for toRequestBody (0.1 sec)

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

          |
          |Fox
          |--123--
          |
          """.trimMargin().replace("\n", "\r\n")
        val body =
          MultipartBody.Builder("123")
            .addPart("Quick".toRequestBody(null))
            .addPart("Brown".toRequestBody(null))
            .addPart("Fox".toRequestBody(null))
            .build()
        assertThat(body.boundary).isEqualTo("123")
        assertThat(body.type).isEqualTo(MultipartBody.MIXED)
        assertThat(body.contentType().toString())
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Mon Jan 08 01:13:22 UTC 2024
    - 10.4K bytes
    - Viewed (0)
  2. okhttp/src/test/java/okhttp3/RequestTest.kt

    import okhttp3.RequestBody.Companion.asRequestBody
    import okhttp3.RequestBody.Companion.toRequestBody
    import okio.Buffer
    import okio.ByteString.Companion.encodeUtf8
    import org.junit.jupiter.api.Test
    
    class RequestTest {
      @Test
      fun constructor() {
        val url = "https://example.com/".toHttpUrl()
        val body = "hello".toRequestBody()
        val headers = headersOf("User-Agent", "RequestTest")
        val method = "PUT"
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Mon Jan 08 01:13:22 UTC 2024
    - 16.4K bytes
    - Viewed (0)
  3. okhttp/src/main/kotlin/okhttp3/RequestBody.kt

        @JvmStatic
        @JvmName("create")
        fun String.toRequestBody(contentType: MediaType? = null): RequestBody {
          val (charset, finalContentType) = contentType.chooseCharset()
          val bytes = toByteArray(charset)
          return bytes.toRequestBody(finalContentType, 0, bytes.size)
        }
    
        @JvmStatic
        @JvmName("create")
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Thu Jan 25 14:41:37 UTC 2024
    - 9.6K bytes
    - Viewed (0)
  4. okhttp/src/test/java/okhttp3/RequestBodyTest.kt

        assertOnFileDescriptor { fd ->
          val requestBody = fd.toRequestBody()
    
          assertThat(requestBody.contentLength()).isEqualTo(-1L)
          assertThat(requestBody.isOneShot()).isEqualTo(true)
        }
      }
    
      @Test
      fun testFileDescriptorRead() {
        assertOnFileDescriptor(content = "Hello") { fd ->
          val requestBody = fd.toRequestBody()
    
          val buffer = Buffer()
          requestBody.writeTo(buffer)
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Mon Jan 08 01:13:22 UTC 2024
    - 3.6K bytes
    - Viewed (0)
  5. samples/guide/src/main/java/okhttp3/recipes/kt/PostString.kt

    import java.io.IOException
    import okhttp3.HttpUrl.Companion.toHttpUrl
    import okhttp3.MediaType.Companion.toMediaType
    import okhttp3.OkHttpClient
    import okhttp3.Request
    import okhttp3.RequestBody.Companion.toRequestBody
    
    class PostString {
      private val client = OkHttpClient()
    
      fun run() {
        val postBody =
          """
          |Releases
          |--------
          |
          | * _1.0_ May 6, 2013
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Mon Jan 08 01:13:22 UTC 2024
    - 1.6K bytes
    - Viewed (0)
  6. okhttp/src/test/java/okhttp3/CommonRequestBodyTest.kt

    package okhttp3
    
    import assertk.assertThat
    import assertk.assertions.isEqualTo
    import kotlin.test.Test
    import okhttp3.RequestBody.Companion.toRequestBody
    
    class CommonRequestBodyTest {
      @Test
      fun correctContentType() {
        val body = "Body"
        val requestBody = body.toRequestBody(MediaType("text/plain", "text", "plain", arrayOf()))
    
        val contentType = requestBody.contentType()!!
    
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Wed Dec 20 23:27:07 UTC 2023
    - 1.1K bytes
    - Viewed (0)
  7. okhttp/src/test/java/okhttp3/DuplexTest.kt

    import mockwebserver3.MockWebServer
    import mockwebserver3.internal.duplex.MockStreamHandler
    import okhttp3.Credentials.basic
    import okhttp3.Headers.Companion.headersOf
    import okhttp3.RequestBody.Companion.toRequestBody
    import okhttp3.TestUtil.assumeNotWindows
    import okhttp3.internal.RecordingOkAuthenticator
    import okhttp3.internal.duplex.AsyncRequestBody
    import okhttp3.testing.PlatformRule
    import okio.BufferedSink
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Sat Jan 20 10:30:28 UTC 2024
    - 23.9K bytes
    - Viewed (0)
  8. okhttp/src/test/java/okhttp3/KotlinSourceModernTest.kt

          }
        requestBody = "".toRequestBody(null)
        requestBody = "".toRequestBody("".toMediaTypeOrNull())
        requestBody = ByteString.EMPTY.toRequestBody(null)
        requestBody = ByteString.EMPTY.toRequestBody("".toMediaTypeOrNull())
        requestBody = byteArrayOf(0, 1).toRequestBody(null, 0, 2)
        requestBody = byteArrayOf(0, 1).toRequestBody("".toMediaTypeOrNull(), 0, 2)
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Mon Apr 01 14:21:25 UTC 2024
    - 46.5K bytes
    - Viewed (0)
  9. docs/changelogs/upgrading_to_okhttp_4.md

    | RequestBody.create(ByteArray)       | ByteArray.toRequestBody()       |
    | RequestBody.create(ByteString)      | ByteString.toRequestBody()      |
    | RequestBody.create(File)            | File.asRequestBody()            |
    | RequestBody.create(String)          | String.toRequestBody()          |
    | ResponseBody.create(BufferedSource) | BufferedSource.asResponseBody() |
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Sun Feb 06 16:58:16 UTC 2022
    - 10.9K bytes
    - Viewed (0)
  10. okhttp/src/test/java/okhttp3/MultipartReaderTest.kt

        val body =
          MultipartBody.Builder("boundary")
            .setType(MultipartBody.PARALLEL)
            .addPart("Quick".toRequestBody("text/plain".toMediaType()))
            .addFormDataPart("color", "Brown")
            .addFormDataPart("animal", "fox.txt", "Fox".toRequestBody())
            .build()
    
        val bodyContent = Buffer()
        body.writeTo(bodyContent)
    
    Registered: Fri Nov 01 11:42:11 UTC 2024
    - Last Modified: Mon Jan 08 01:13:22 UTC 2024
    - 13.8K bytes
    - Viewed (0)
Back to top