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

Ian Partridge ian at poncho.org.uk
Thu Nov 16 14:15:19 CST 2017

On 16 November 2017 at 19:02, Alex Blewitt <alblue at apple.com> wrote:
> Note that there's no requirement for the methods to be capitalised in URLRequest.

I'm not sure what you mean by requirement.  It may not be documented,
but Darwin does behave this way.

> 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.

Perhaps. That's what I'd like to enquire about.  Is making SCLF
compatible with the output in my example sufficient, or are there
other factors to consider?

> I also don't think it makes sense to capitalise everything because in most cases it will have no effect, but is wasted computation.

Darwin doesn't capitalise everything, as I've shown, so SCLF shouldn't either.

> So in other words, don't pass lowercase values into the x.httpMethod if you don't want it.

I'm sorry, I don't understand this.

x.httpMethod accepts an arbitrary String - you can write `x.httpMethod
= frobnicate` if you want.

Darwin seems to treat some values e.g. "get" specially though. This
isn't documented, but SCLF should behave the same because there's code
out there that does `x.httpMethod = "get"`, `y.httpMethod = "GET",
compares the URLRequests and expects them to be equal.

Ian Partridge

More information about the swift-corelibs-dev mailing list