f3ath/dart-http-interop

Empty Text in Body Constructor Should Return Empty Stream or Null instead of [[]]

Closed this issue · 3 comments

Current:
When initializing the Body object with an empty text parameter, the resulting stream contains an empty list ([[]]).

Body(String text, Encoding encoding)
    : this.binary(Uint8List.fromList(encoding.encode(''))); 
    // Returns [[]] via Body.binary constructor

Expected:
When the text parameter is empty, the stream should ideally be empty as well, instead of returning [[]].
Alternatively, returning null might be a more intuitive and cleaner solution. However, I understand this might complicate things due to structural changes in the code.

f3ath commented

Thank you!

f3ath commented

@aliaksei-liavonik please LMK if the fix works for you.

f3ath commented

Closing as fixed