Godot: HTTPClient is_response_chunked (seemingly) always returns false

Created on 4 Feb 2020  路  2Comments  路  Source: godotengine/godot

Godot version:
3.2 Release

OS/device including version:
Linux Mint 19.3

Issue description:
httpclient.is_response_chunked() == false even though the response is split into chunks

Steps to reproduce:
Load a file >4096 bytes and read the output. It will be chunked regardless of is_response_chunked()

const MY_HOST := "https://gist.githubusercontent.com"
const MY_EP := "/The5heepDev/a15539b297a7862af4f12ce07fee6bb7/raw/7164813a9b8d0a3b2dcffd5b80005f1967887475/entire_bee_movie_script"

func _ready() -> void:
    var httpclient := HTTPClient.new()

    assert(httpclient.connect_to_host(MY_HOST, -1, true) == OK)
    while httpclient.get_status() == HTTPClient.STATUS_RESOLVING or httpclient.get_status() == HTTPClient.STATUS_CONNECTING:
        assert(httpclient.poll() == OK)
        yield(Engine.get_main_loop(), "idle_frame")

    print(MY_HOST + MY_EP)

    assert(httpclient.request(HTTPClient.METHOD_GET, MY_EP, []) == OK)
    while httpclient.get_status() == HTTPClient.STATUS_REQUESTING:
        assert(httpclient.poll() == OK)
        yield(Engine.get_main_loop(), "idle_frame")

    print()
    print("Chunked?: " + str(httpclient.is_response_chunked()))
    print("Full Body: " + str(httpclient.get_response_body_length()))
    print()
    while httpclient.get_status() == HTTPClient.STATUS_BODY:
        var size := httpclient.read_response_body_chunk().size()
        if size != 0:
            print("Chunk: " + str(size))

Minimal reproduction project:
Test7.zip

bug network

Most helpful comment

Some additional context for this issue:

Overlapping use of "chunk" terminology

As I discovered when investigating a different issue it seems that the HTTPClient code seems to use the term "chunk" to refer to two different concepts:

1) "chunk" in the sense of _HTTP's "Chunked transfer encoding"_; and,

2) "chunk" in the generic sense of _"some quantity of bytes"_.

The documentation doesn't currently clarify which meaning applies in each case and the implementation also obscures the difference.

Matching properties/methods to each meaning of "chunk"

So, as I understand it:

Summary

Thus, based on my understanding this isn't a bug but is a documentation issue.

(In theory it might be considered an implementation wart that the read_chunk_size value is ignored when Chunked Transfer Encoding is used.)

Hope this is some helpful context.


[0] Although the wording could definitely still be improved to be both accurate and actually helpful. :D

All 2 comments

Some additional context for this issue:

Overlapping use of "chunk" terminology

As I discovered when investigating a different issue it seems that the HTTPClient code seems to use the term "chunk" to refer to two different concepts:

1) "chunk" in the sense of _HTTP's "Chunked transfer encoding"_; and,

2) "chunk" in the generic sense of _"some quantity of bytes"_.

The documentation doesn't currently clarify which meaning applies in each case and the implementation also obscures the difference.

Matching properties/methods to each meaning of "chunk"

So, as I understand it:

Summary

Thus, based on my understanding this isn't a bug but is a documentation issue.

(In theory it might be considered an implementation wart that the read_chunk_size value is ignored when Chunked Transfer Encoding is used.)

Hope this is some helpful context.


[0] Although the wording could definitely still be improved to be both accurate and actually helpful. :D

All of follower's analysis is correct. I do want to clarify that as per the http spec, when chunked transfer encoding is used, the chunk size should always be derived from the beginning of the response body. This is why "read_chunk_suze is ignored in this case. I agree that variable's name could be less conflated though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timoschwarzer picture timoschwarzer  路  3Comments

gonzo191 picture gonzo191  路  3Comments

mefihl picture mefihl  路  3Comments

Zylann picture Zylann  路  3Comments

nunodonato picture nunodonato  路  3Comments