Opened 8 years ago

Closed 8 years ago

#5460 closed defect (invalid)

http.c module, custom headers are lost

Reported by: Kow Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: http
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: using ffmpeg/ffplay passing multiples custom http headers only the user-agent and the last header are kept.
All the other custom headers are ignored and substituted by the default ones.
How to reproduce:

ffmpeg -v debug -user-agent 'Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0' -headers 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'$'\r\n' -headers 'Accept-Language: en-US,en;q=0.8,es-ES;q=0.5,es;q=0.3'$'\r\n' -headers 'Accept-Encoding: gzip, deflate'$'\r\n' -headers 'DNT: 1'$'\r\n' -headers 'Referer: http://www.ponlatv.com/jwplayer6/jwplayer.flash.swf'$'\r\n' -headers 'Connection: keep-alive'$'\r\n' -i 'http://cdn.sstream.pw/live/cuatro_xrf2a3/playlist.m3u8?st=8If-lp-putG5fQ_PAioD-Q&e=1460073969' - | ffplay -

This will produce the following log:

ffplay version 3.0.1ffmpeg version 3.0.1 Copyright (c) 2003-2016 the FFmpeg developers

Copyright (c) 2000-2016 the FFmpeg developers

built with gcc 4.9.2 (GCC)
configuration: --enable-libfaac --enable-libx264 --enable-gpl --enable-nonfree --enable-ffplay --enable-sdl --enable-gnutls --enable-openssl
built with gcc 4.9.2 (GCC)
configuration: --enable-libfaac --enable-libx264 --enable-gpl --enable-nonfree --enable-ffplay --enable-sdl --enable-gnutls --enable-openssl
libavutil 55. 17.103 / 55. 17.103
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
libpostproc 54. 0.100 / 54. 0.100

Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-user-agent' ... matched as AVOption 'user-agent' with argument 'Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0'.
Reading option '-headers' ... matched as AVOption 'headers' with argument 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
'.
Reading option '-headers' ... matched as AVOption 'headers' with argument 'Accept-Language: en-US,en;q=0.8,es-ES;q=0.5,es;q=0.3
'.
Reading option '-headers' ... matched as AVOption 'headers' with argument 'Accept-Encoding: gzip, deflate
'.
Reading option '-headers' ... matched as AVOption 'headers' with argument 'DNT: 1
'.
Reading option '-headers' ... matched as AVOption 'headers' with argument 'Referer: http://www.ponlatv.com/jwplayer6/jwplayer.flash.swf
'.
Reading option '-headers' ... matched as AVOption 'headers' with argument 'Connection: keep-alive
'.
Reading option '-i' ... matched as input file with argument 'http://cdn.sstream.pw/live/cuatro_xrf2a3/playlist.m3u8?st=8If-lp-putG5fQ_PAioD-Q&e=1460073969'.
Reading option '-' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input file http://cdn.sstream.pw/live/cuatro_xrf2a3/playlist.m3u8?st=8If-lp-putG5fQ_PAioD-Q&e=1460073969.
Successfully parsed a group of options.
Opening an input file: http://cdn.sstream.pw/live/cuatro_xrf2a3/playlist.m3u8?st=8If-lp-putG5fQ_PAioD-Q&e=1460073969.
[http @ 0x1f2c0c0] Setting default whitelist 'http,https,tls,rtp,tcp,udp,crypto,httpproxy'
[http @ 0x1f2c0c0] request: GET /live/cuatro_xrf2a3/playlist.m3u8?st=8If-lp-putG5fQ_PAioD-Q&e=1460073969 HTTP/1.1
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Accept: */*
Range: bytes=0-
Host: cdn.sstream.pw
Icy-MetaData: 1
Connection: keep-alive

and the connection hangs.

If you remove the last custom header (Connection: keep-alive) you'll see the preceeding header taking place, and so on.

Change History (6)

comment:1 by Carl Eugen Hoyos, 8 years ago

Component: ffmpegundetermined
Keywords: headers removed
Priority: importantnormal

Is the issue reproducible with current FFmpeg git head? Do you think this is a regression?

comment:2 by Kow, 8 years ago

Can't say about regression. Never used multiples custom http headers before.
I'm going to download from git and fbk asap.

Tks for now

comment:3 by Cigaes, 8 years ago

This is not how ffmpeg options work. Giving the same option several times always result in the last copy overriding the previous ones. You could have guessed it by reading carefully the name of the option: -headers, plural.

comment:4 by Kow, 8 years ago

I read about the plural, and attempted any syntax form to assemble the multiples options within a single -headers string before opening the ticket
But I've my fantasy has gone out of stock. No luck.
If you can explain how reach such target I'm glad.
If such kind of possibility exists is quite hidden in the ffmpeg manual that I've read.

Tks again for your help.

comment:5 by Kow, 8 years ago

Found a solution into a forum. Many other people has gotten my same problem about unclear syntax.
Now I've used ffplay.

ffplay -v debug -user-agent 'Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0' -headers 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.8,es-ES;q=0.5,es;q=0.3'$'\r\nAccept-Encoding: gzip, deflate'$'\r\nDNT: 1'$'\r\nReferer: http://www.ponlatv.com/jwplayer6/jwplayer.flash.swf'$'\r\n''Connection: keep-alive'$'\r\nIcy-Metadata: 0'$'\r\n' -i 'http://cdn.sstream.pw/live/cuatro_xrf2a3/playlist.m3u8?st=8If-lp-putG5fQ_PAioD-Q&e=1460073969'

This works, even if I've to force Icy-Metadata 0 to get the stream.
Otherwise the stream doesn't start because the ffmpeg uses as default Icy-Metadata 1.

This ticket can be closed.

Tks for your help

comment:6 by Carl Eugen Hoyos, 8 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.