如何将小写字段添加到NSURLRequest头字段? [英] How to add lowercase field to NSURLRequest header field?

查看:107
本文介绍了如何将小写字段添加到NSURLRequest头字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很沮丧地弄清楚如何将小写标题字段添加到NSMutableURLRequest。

I'm getting pretty frustrated figuring out how to add a lowercase header field to an NSMutableURLRequest.

NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:MyURLString]];
[urlRequest setValue:@"aValue" forHTTPHeaderField:@"field"];

在上面的示例中,field切换到Field,因为标题字段名称是不区分大小写。我认为这不应该发生,但确实如此。我正在使用的API区分大小写,因此我的GET请求被忽略。有没有办法覆盖案例开关?

In the example above, "field" gets switched to "Field," since the header field names are case insensitive. I would think this shouldn't happen, but it does. The API I am working with is case sensitive, so my GET request is ignored. Is there any way to override the case switch?

推荐答案

我写了一篇关于这个主题的博文:修复 - [NSMutableURLRequest setValue:forHTTPHeaderField:] 我建议你阅读它。您将学习如何解决此问题以及为什么不应该修复它。

I have written a blog post on the topic: Fixing -[NSMutableURLRequest setValue:forHTTPHeaderField:] I suggest you to read it. You will learn how to fix this problem and why you should not fix it.

这篇关于如何将小写字段添加到NSURLRequest头字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆