Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zhengwu119 opened this issue Dec 9, 2016 · 5 comments
Open

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

zhengwu119 opened this issue Dec 9, 2016 · 5 comments

Comments

@zhengwu119
Copy link

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

谢谢~

@xinzhengzhang
Copy link
Member

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
Copy link
Member

raymond1012 commented Feb 9, 2017 via email

@ghost
Copy link

ghost commented Mar 26, 2017

[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
Copy link

Zeaa commented Feb 6, 2018

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

@DengJPeng
Copy link

[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,大神有遇到吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants