Giter VIP home page Giter VIP logo

Comments (9)

vbuberen avatar vbuberen commented on August 23, 2024 2

Hey @DE-DuyTran
Do you still experience this issue?
If so, could you provide details requested by @cortinico in the message above?

from chucker.

DE-DuyTran avatar DE-DuyTran commented on August 23, 2024 1

@cortinico @vbuberen
Sorry for very late reply...
This is my answer.

  • What does can't upload file via multipart?
    I upload Image file (JPEG) to attach with json body.

  • Are you getting a HTTP error code?
    What i receive from LogCat
    "com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream"
    "java.net.ProtocolException: unexpected end of stream"

  • Do you have any stacktrace to share?
    handlerError:170, BaseDisposable (xxxx.model.base)
    access$handlerError:40, BaseDisposable (xxxx.model.base)
    accept:92, BaseDisposable$startWithoutCheckNetwork$1 (xxxx.model.base)
    accept:40, BaseDisposable$startWithoutCheckNetwork$1 (xxxx.model.base)
    onError:114, ObservableDoOnEach$DoOnEachObserver (io.reactivex.internal.operators.observable)
    checkTerminated:276, ObservableObserveOn$ObserveOnObserver (io.reactivex.internal.operators.observable)
    drainNormal:172, ObservableObserveOn$ObserveOnObserver (io.reactivex.internal.operators.observable)
    run:252, ObservableObserveOn$ObserveOnObserver (io.reactivex.internal.operators.observable)
    run:119, HandlerScheduler$ScheduledRunnable (io.reactivex.android.schedulers)
    handleCallback:873, Handler (android.os)
    dispatchMessage:99, Handler (android.os)
    loop:201, Looper (android.os)
    main:6806, ActivityThread (android.app)
    invoke:-1, Method (java.lang.reflect)
    run:547, RuntimeInit$MethodAndArgsCaller (com.android.internal.os)
    main:873, ZygoteInit (com.android.internal.os)

  • Is the app crashing?
    It's no crashing.

  • Is this issue happening only for multipart requests?
    I'm not yet test for other case.

from chucker.

vbuberen avatar vbuberen commented on August 23, 2024 1

Thanks a lot for such a detailed input.
I searched through issues in Fast Android Networking and found an issue, which looks quite similar to what you described: amitshekhariitbhu/Fast-Android-Networking#464
If it happens to be the same issue, it seems that it is not Chucker, but Fast Android Networking.

from chucker.

vbuberen avatar vbuberen commented on August 23, 2024 1

I guess, we can close it, since no other reports here.

from chucker.

olegsvs avatar olegsvs commented on August 23, 2024 1

HI @vbuberen
Similar with ktor(1.5.0/1.5.2) and multipart upload
with chucker(3.4.0):

I/System.out: File exists: IMG_20210329_084101.jpg, size=31660
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] REQUEST: https://*.*/blabla
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] METHOD: HttpMethod(value=PUT)
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] COMMON HEADERS
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Accept: application/json
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Accept-Charset: UTF-8
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Authorization: blabla
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Cache-Control: private
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] CONTENT HEADERS
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Content-Length: 32085
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Content-Type: multipart/form-data; boundary=-681f0d6a310571652db4fcd412f01206-38c3e46b45ddb43479b39dfc-30c76d864e3
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] BODY Content-Type: multipart/form-data; boundary=-681f0d6a310571652db4fcd412f01206-38c3e46b45ddb43479b39dfc-30c76d864e3
I/i.k.c.HttpClient.log: [OkHttp https://*.*/...] BODY START
I/i.k.c.HttpClient.log: [OkHttp https://*.*/...] [request body omitted]
I/i.k.c.HttpClient.log: [OkHttp https://*.*/...] BODY END
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-3] REQUEST https://*.*/blabla failed with exception: java.net.ProtocolException: unexpected end of stream

 Caused by: java.net.ProtocolException: unexpected end of stream
	at okhttp3.internal.connection.Exchange$RequestBodySink.close(Exchange.kt:239)
	at okio.RealBufferedSink.close(RealBufferedSink.kt:268)
	at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:60)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at com.chuckerteam.chucker.api.ChuckerInterceptor.intercept(ChuckerInterceptor.kt:114)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:502)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)

without chucker ok:

I/System.out: File exists: IMG_20210329_084101.jpg, size=31660
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] REQUEST: https://*.*/blabla
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] METHOD: HttpMethod(value=PUT)
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] COMMON HEADERS
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Accept: application/json
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Accept-Charset: UTF-8
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Authorization: blabla
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Cache-Control: private
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] CONTENT HEADERS
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Content-Length: 32085
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] -> Content-Type: multipart/form-data; boundary=6538ee3e2b1702c55849d34-6c66f14c702565c15406a4a4-7b253755310821926b054
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] BODY Content-Type: multipart/form-data; boundary=6538ee3e2b1702c55849d34-6c66f14c702565c15406a4a4-7b253755310821926b054
I/i.k.c.HttpClient.log: [OkHttp https://*.*/...] BODY START
I/i.k.c.HttpClient.log: [OkHttp https://*.*/...] [request body omitted]
I/i.k.c.HttpClient.log: [OkHttp https://*.*/...] BODY END
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] RESPONSE: 200 OK
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] METHOD: HttpMethod(value=PUT)
I/i.k.c.HttpClient.log: [DefaultDispatcher-worker-1] FROM: https://*.*/blabla

method for upload:

suspend fun attachFile(
        context: Context,
        uri: Uri,
        fileName: String,
        fileSizeByte: Long
    ) {
        client.request<HttpResponse> {
            apiUrl("blabla")
            method = HttpMethod.Put
            body = MultiPartFormDataContent(
                formData {
                    appendInput(
                        key = "encode-base64-scan",
                        headers = Headers.build {
                            append(HttpHeaders.ContentLength, fileSizeByte)
                            append(HttpHeaders.ContentDisposition, "filename=${fileName}")
                        },
                        size = fileSizeByte
                    ) {
                        buildPacket {
                            context.contentResolver.openInputStream(uri)!!.use {
                                writeFully(it.readBytes())
                            }
                        }
                    }
                }
            )
        }
    }

https://github.com/ChuckerTeam/chucker/blob/3.x/library/src/main/java/com/chuckerteam/chucker/api/ChuckerInterceptor.kt#L114

from chucker.

cortinico avatar cortinico commented on August 23, 2024

Hey @DE-DuyTran
Thanks for the report. Can you please provide more context?

  • What does can't upload file via multipart?
  • Are you getting a HTTP error code?
  • Do you have any stacktrace to share?
  • Is the app crashing?
  • Is this issue happening only for multipart requests?

Ideally if you could provide also a sample project where we can reproduce the issue, would be awesome.

from chucker.

cortinico avatar cortinico commented on August 23, 2024

HI @vbuberen
Similar with ktor(1.5.0/1.5.2) and multipart upload

Please open a new issue.
Also I'm unsure how KTor is relevant here as Chucker works only with OkHTTP

from chucker.

MiSikora avatar MiSikora commented on August 23, 2024

Also I'm unsure how KTor is relevant here as Chucker works only with OkHTTP

You can install OkHttp as an underlying client.

from chucker.

cortinico avatar cortinico commented on August 23, 2024

You can install OkHttp as an underlying client.

TIL :O

from chucker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.