bilibili / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
GNU General Public License v2.0
32.46k stars 8.12k forks source link

请问下iOS下能否设置自定义请求头? #2415

Open zhengwu119 opened 7 years ago

zhengwu119 commented 7 years ago

类似这样的参数: [request addValue:@"www.bilibili.com" forHTTPHeaderField:@"Host"];

谢谢~

xinzhengzhang commented 7 years ago

See http.c { "headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D | E },

raymond1012 commented 7 years ago

https://www.ffmpeg.org/ffmpeg-protocols.html#Protocol-Options

2017-02-08 19:51 GMT+08:00 15031980193 notifications@github.com:

这个http.c在哪里? 能说下具体咋用吗,Android上如何设置自定义的请求头?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Bilibili/ijkplayer/issues/2415#issuecomment-278307378, or mute the thread https://github.com/notifications/unsubscribe-auth/AEOmlgwEAEUhzZMnmG-fS1-_C8aNktLKks5raaxCgaJpZM4LIybi .

ghost commented 7 years ago
[options setFormatOptionValue:@"Referer:http://github.com\r\nRange:byte=1-1000" forKey:@"headers"];

这样就可以了设置http访问的Referer 为http://github.com,和Range头为byte=1-1000.

http头本身就是使用\r\n进行分隔的,所以可以自定义http的头信息, 楼上 @raymond1012 已经给出如何如何设置http头的描述。

vitamio的iOS版本设置http头的方式也是类似的方式,为什么呢?原因 @raymond1012 发的链接已经说得很清楚了,如下

headers
Set custom HTTP headers, can override built in default headers. The value must be a string encoding the headers.
Zeaa commented 6 years ago

你想要替换Host的话得这样设置,注意:host:后面有空格,host:后面有空格,host:后面有空格,可以设置日志等级为k_IJK_LOG_INFO,在控制台中查看 [options setFormatOptionValue:@"host: mpv.videocc.net" forKey:@"headers"];

DengJPeng commented 3 years ago
[options setFormatOptionValue:@"Referer:http://github.com\r\nRange:byte=1-1000" forKey:@"headers"];

这样就可以了设置http访问的Referer为http://github.com,和范围头为byte = 1-1000

http头本身就是使用\ r \ n进行分隔的,所以可以自定义http的头信息, 楼上@ raymond1012已经意识到如何设置http头的描述。

vitamio的iOS版本设置http头的方式也是类似的方式,为什么呢?原因@ raymond1012发的链接已经说得很清楚了,如下

headers
Set custom HTTP headers, can override built in default headers. The value must be a string encoding the headers.

ijkplyaer设置 Range:byte=1-1000后,视频时长异常都是2s,大神有遇到吗