http: Reset compressed header flag when starting to read a request

Message ID 20170915115903.79215-1-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Sept. 15, 2017, 11:59 a.m.
From: Jacek Jendrzej <satbaby@kawaii.com>

This fixes redirects, where the original redirect response indicated
support for compression, while the actual redirected content didn't.
---
 libavformat/http.c | 1 +
 1 file changed, 1 insertion(+)

Comments

James Almer Sept. 15, 2017, 2:18 p.m. | #1
On 9/15/2017 8:59 AM, Martin Storsjö wrote:
> From: Jacek Jendrzej <satbaby@kawaii.com>
> 
> This fixes redirects, where the original redirect response indicated
> support for compression, while the actual redirected content didn't.
> ---
>  libavformat/http.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 00cf295001..ef52bc1034 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -682,6 +682,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
>      s->willclose        = 0;
>      s->end_chunked_post = 0;
>      s->end_header       = 0;
> +    s->compressed       = 0;
>      if (post && !s->post_data && !send_expect_100) {
>          /* Pretend that it did work. We didn't read any header yet, since
>           * we've still to send the POST data, but the code calling this
> 

You should also cherry-pick
https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=6743351558001764d662bb52b9a3e0bbb63366d6
as it fixes a compilation failure without zlib introduced by this patch.
Martin Storsjö Sept. 15, 2017, 9:24 p.m. | #2
On Fri, 15 Sep 2017, James Almer wrote:

> On 9/15/2017 8:59 AM, Martin Storsjö wrote:
>> From: Jacek Jendrzej <satbaby@kawaii.com>
>> 
>> This fixes redirects, where the original redirect response indicated
>> support for compression, while the actual redirected content didn't.
>> ---
>>  libavformat/http.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/libavformat/http.c b/libavformat/http.c
>> index 00cf295001..ef52bc1034 100644
>> --- a/libavformat/http.c
>> +++ b/libavformat/http.c
>> @@ -682,6 +682,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
>>      s->willclose        = 0;
>>      s->end_chunked_post = 0;
>>      s->end_header       = 0;
>> +    s->compressed       = 0;
>>      if (post && !s->post_data && !send_expect_100) {
>>          /* Pretend that it did work. We didn't read any header yet, since
>>           * we've still to send the POST data, but the code calling this
>> 
>
> You should also cherry-pick
> https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=6743351558001764d662bb52b9a3e0bbb63366d6
> as it fixes a compilation failure without zlib introduced by this patch.

Thanks - squashed that into the patch locally.

// Martin
Martin Storsjö Sept. 26, 2017, 8:41 a.m. | #3
On Sat, 16 Sep 2017, Martin Storsjö wrote:

> On Fri, 15 Sep 2017, James Almer wrote:
>
>> On 9/15/2017 8:59 AM, Martin Storsjö wrote:
>>> From: Jacek Jendrzej <satbaby@kawaii.com>
>>> 
>>> This fixes redirects, where the original redirect response indicated
>>> support for compression, while the actual redirected content didn't.
>>> ---
>>>  libavformat/http.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>> 
>>> diff --git a/libavformat/http.c b/libavformat/http.c
>>> index 00cf295001..ef52bc1034 100644
>>> --- a/libavformat/http.c
>>> +++ b/libavformat/http.c
>>> @@ -682,6 +682,7 @@ static int http_connect(URLContext *h, const char 
> *path, const char *local_path,
>>>      s->willclose        = 0;
>>>      s->end_chunked_post = 0;
>>>      s->end_header       = 0;
>>> +    s->compressed       = 0;
>>>      if (post && !s->post_data && !send_expect_100) {
>>>          /* Pretend that it did work. We didn't read any header yet, since
>>>           * we've still to send the POST data, but the code calling this
>>> 
>>
>> You should also cherry-pick
>> 
> https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=6743351558001764d662bb52b9a3e0bbb63366d6
>> as it fixes a compilation failure without zlib introduced by this patch.
>
> Thanks - squashed that into the patch locally.

Any further comments or approvals for this patch?

// Martin
Luca Barbato Sept. 26, 2017, 9:22 a.m. | #4
On 26/09/2017 10:41, Martin Storsjö wrote:
> On Sat, 16 Sep 2017, Martin Storsjö wrote:
> 
>> On Fri, 15 Sep 2017, James Almer wrote:
>>
>>> On 9/15/2017 8:59 AM, Martin Storsjö wrote:
>>>> From: Jacek Jendrzej <satbaby@kawaii.com>
>>>>
>>>> This fixes redirects, where the original redirect response indicated
>>>> support for compression, while the actual redirected content didn't.
>>>> ---
>>>>  libavformat/http.c | 1 +
>>>>  1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/libavformat/http.c b/libavformat/http.c
>>>> index 00cf295001..ef52bc1034 100644
>>>> --- a/libavformat/http.c
>>>> +++ b/libavformat/http.c
>>>> @@ -682,6 +682,7 @@ static int http_connect(URLContext *h, const char 
>> *path, const char *local_path,
>>>>      s->willclose        = 0;
>>>>      s->end_chunked_post = 0;
>>>>      s->end_header       = 0;
>>>> +    s->compressed       = 0;
>>>>      if (post && !s->post_data && !send_expect_100) {
>>>>          /* Pretend that it did work. We didn't read any header yet, 
>>>> since
>>>>           * we've still to send the POST data, but the code calling 
>>>> this
>>>>
>>>
>>> You should also cherry-pick
>>>
>> https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=6743351558001764d662bb52b9a3e0bbb63366d6 
>>
>>> as it fixes a compilation failure without zlib introduced by this patch.
>>
>> Thanks - squashed that into the patch locally.
> 
> Any further comments or approvals for this patch?
> 

Shouldn't hurt. go for it :)

lu
Rémi Denis-Courmont Sept. 26, 2017, 3:51 p.m. | #5
Le tiistaina 26. syyskuuta 2017, 11.41.32 EEST Martin Storsjö a écrit :
> On Sat, 16 Sep 2017, Martin Storsjö wrote:
> > On Fri, 15 Sep 2017, James Almer wrote:
> >> On 9/15/2017 8:59 AM, Martin Storsjö wrote:
> >>> From: Jacek Jendrzej <satbaby@kawaii.com>
> >>> 
> >>> This fixes redirects, where the original redirect response indicated
> >>> support for compression, while the actual redirected content didn't.
> >>> ---
> >>> 
> >>>  libavformat/http.c | 1 +
> >>>  1 file changed, 1 insertion(+)
> >>> 
> >>> diff --git a/libavformat/http.c b/libavformat/http.c
> >>> index 00cf295001..ef52bc1034 100644
> >>> --- a/libavformat/http.c
> >>> +++ b/libavformat/http.c
> >>> @@ -682,6 +682,7 @@ static int http_connect(URLContext *h, const char
> > 
> > *path, const char *local_path,
> > 
> >>>      s->willclose        = 0;
> >>>      s->end_chunked_post = 0;
> >>>      s->end_header       = 0;
> >>> 
> >>> +    s->compressed       = 0;
> >>> 
> >>>      if (post && !s->post_data && !send_expect_100) {
> >>>      
> >>>          /* Pretend that it did work. We didn't read any header yet,
> >>>          since
> >>>          
> >>>           * we've still to send the POST data, but the code calling this
> >> 
> >> You should also cherry-pick
> > 
> > https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=6743351558001764d662
> > bb52b9a3e0bbb63366d6> 
> >> as it fixes a compilation failure without zlib introduced by this patch.
> > 
> > Thanks - squashed that into the patch locally.
> 
> Any further comments or approvals for this patch?

Not really. On a loosely related note, it looks like libavformat incorrectly 
combines content-range and content-encoding, effectively mistaking content-
encoding for transfer-encoding.

IMO, decoding the content-encoding at the HTTP layer is hazardous precisely 
because of that distinction.

Patch

diff --git a/libavformat/http.c b/libavformat/http.c
index 00cf295001..ef52bc1034 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -682,6 +682,7 @@  static int http_connect(URLContext *h, const char *path, const char *local_path,
     s->willclose        = 0;
     s->end_chunked_post = 0;
     s->end_header       = 0;
+    s->compressed       = 0;
     if (post && !s->post_data && !send_expect_100) {
         /* Pretend that it did work. We didn't read any header yet, since
          * we've still to send the POST data, but the code calling this