[swift-corelibs-dev] SR-6405: URLRequest does not capitalise HTTP methods

Alex Blewitt alblue at apple.com
Thu Nov 16 13:02:05 CST 2017


There is a TestFoundation target in the swift-corelibs-foundation project, which can allow the tests to be run against the open source codebase.

Note that there's no requirement for the methods to be capitalised in URLRequest. Chances are that the implementation is such that there are some pre-defined values which can be used/replaced for keys, but other ones will take the case of whatever you put in them.

I also don't think it makes sense to capitalise everything because in most cases it will have no effect, but is wasted computation. So in other words, don't pass lowercase values into the x.httpMethod if you don't want it.

Alex

> On 16 Nov 2017, at 17:41, Stephen Celis via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
> 
> Brandon Williams and I have come across a lot of inconsistencies between Foundations in our Swift web work. We’ve been trying to file bugs when we remember to, but I’m curious if there’s a better way to catch these. Is the Foundation test suite run against both implementations to attempt to catch these kinds of things? If not it would seem like a big win to do so. If so, I suppose we could help by beefing up the test coverage?
> 
> Stephen
> 
>> On Nov 16, 2017, at 12:18 PM, Ian Partridge via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
>> 
>> Hi, it looks like Foundation on Darwin capitalises certain HTTP
>> methods but not others:
>> 
>> ```
>> let methods = ["get", "head", "post", "put", "delete", "connect",
>> "options", "trace", "patch"]
>> 
>> var x = URLRequest(url: URL(string: "/hello")!)
>> 
>> for m in methods {
>>   x.httpMethod = m
>>   print(x.httpMethod!)
>> }
>> ```
>> 
>> Output on Darwin:
>> GET
>> HEAD
>> POST
>> PUT
>> DELETE
>> CONNECT
>> options
>> trace
>> patch
>> 
>> Currently on Linux we don't do any capitalization so I'd like to fix this.
>> 
>> Is my list of 6 methods above the definitive list of which HTTP
>> methods should be capitalized?
>> 
>> Thanks,
>> 
>> -- 
>> Ian Partridge
>> _______________________________________________
>> swift-corelibs-dev mailing list
>> swift-corelibs-dev at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
> 
> _______________________________________________
> swift-corelibs-dev mailing list
> swift-corelibs-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev



More information about the swift-corelibs-dev mailing list