elm / http

Make HTTP requests in Elm
https://package.elm-lang.org/packages/elm/http/latest
BSD 3-Clause "New" or "Revised" License
155 stars 46 forks source link

Can Http.Receiving not handle data that is more than 1023 byte? #71

Open koji-k opened 4 years ago

koji-k commented 4 years ago

I am trying to track size of received data of http response (Http.Receiving).

Elm codes works fine. But size of Http.Receiving seems to have a problem.

Specifically, size of Http.Receiving will be set Nothing when Content-Length is more than 1023 byte. If Content-Length smaller than 1024 byte, it is no problem.

I think event.lengthComputable returns false when Content-Length more than 1023 byte. But i don't know why realize so...

https://github.com/elm/http/blob/master/src/Elm/Kernel/Http.js#L183

I wrote following debug print function execute in update.

printProgress : Http.Progress -> String
printProgress progress =
    case progress of
        Sending record ->
            "Sending: sent=" ++ String.fromInt record.sent

        Receiving record ->
            "Receiving:"
                ++ " received="
                ++ String.fromInt record.received
                ++ ", size="
                ++ (Maybe.withDefault -1 record.size |> String.fromInt)

Result of response with 1023 byte:

Result of response with 1024 byte:

received has problem too on Firefox.

Is there something workaround?