Open TijnvandenEijnde opened 7 months ago
cc @brianquinlan and @natebosch
@TijnvandenEijnde Thanks for very the detailed bug report!
My first impression is that this would be difficult to support because the HttpClient
API assumes that the complete set of headers have been received before streaming the response.
I wonder if using package:cupertino_http
or package:cronet_http
would fix this problem.
this would be difficult to support because the
HttpClient
API assumes that the complete set of headers have been received before streaming the response.
I think either silently ignoring the trailing header (assuming we cannot or should not add to the header map) or throwing a more actionable exception would be an improvement on the current behavior.
@brianquinlan You are welcome and thank you for the response!
It would be nice if the regular HttpClient
could handle it. However, having to redesign the HttpClient
for what I think is an edge case does not make much sense.
I have seen the above-mentioned URL with the Trailer
header work in Android applications so I think package:cronet_http
will fix the problem. I will test it out in the future and give you an update.
@TijnvandenEijnde That's so much and let us know if package:cronet_http
fixes the problem.
Problem
I am trying to make a connection with the following URL: https://www.popularmechanics.com/rss/science/?src=rss. In my browser, everything seems fine. However, when I try to retrieve the URL using
.get()
function from thehttp
package. I get the following exception:ClientException: Failed to parse HTTP, 115 does not match 13, uri=https://popularmechanics.com/rss/science/?src=rss
.Here is a simplified version of my code:
Running the code will give the following:
I thought that it might have something to do with the
http
package so I tried thedio
package as well. However, the same problem still persists:Running the code will give the following:
Cause
The server is sending a rarely used HTTP header called
Trailer
.At the end of the body, it includes the data for this
Trailer
header.The Dart
HttpClient
isn't expecting this appended trailer (or it is malformed). Note how the first character is from the server and this is the 115 it says isn't the 13 it is expecting.Source: ClientException: Failed to parse HTTP, 115 does not match 13
Request
Add support for the Trailer HTTP header to the Dart
HttpClient
.