mylisabox / flutter_mjpeg

Flutter widget to show mjpeg stream from URL
BSD 2-Clause "Simplified" License
32 stars 24 forks source link

Content-Length must contain only digits #41

Closed sotero73 closed 4 months ago

sotero73 commented 4 months ago

Hi, first I would like to thank you for developing this library. Theoretically, it's exactly what I need. However, the MJPEG stream I have from the camera opens normally in the browser but the error "Content-Length must contain only digits" appears in the library. I just provide the mjpeg stream url... what is this error exactly? The url is in this format https://{server}:8100/Mjpeg/1?authToken={token}

jaumard commented 4 months ago

Hey! Thanks for your feedback! Content length is something sent by the server, maybe it try to send a value that doesn't contain digits? Web browser may don't care ^^ maybe try to check what's inside the header of your mjpeg server.

Can't help a lot without access to the stream itself

cybrox commented 4 months ago

@sotero73 Some additional info: This exception is not caused by flutter_mjpeg but the dart http client (here). According to RFC9110 8.6 The "Content-Length" header field indicates the associated representation's data length as a decimal non-negative integer number of octets.

So yes, as was suggested, check the response of your server using curl or a similar tool. It looks like the server sends back bogus data in the Content-Length header.

sotero73 commented 4 months ago

You're right. I tested it with postman and it returned the following error "Parse Error: There seems to be an invalid character in the "Content-Length" response header". The problem is that I can't solve this because I can't change this information on the server. I will have to use the hls stream instead of mjpeg. Thanks.

jaumard commented 4 months ago

Sorry to hear that. Good luck! You might also try to create a quick proxy for the stream and fix the wrong header. That would make it a valid stream.