HTTP Request line decoding

Just a heads-up: in response to a post earlier this week, I have added some sample code to the playground that decodes HTTP request lines.

It seems to work. There's a kajillion ways to do the job, of course, many of them arguably better than my attempt. If anyone here has strong feelings on the matter, please feel free to add your own sample code to the playground as I did.

Does your post belong in Exhibition?

The solution is remarkable in that it avoids the use of the String class. Well done.

Meh - it's mainly in response to various posts on this sub. This is the more "programming" side of the community.

The solution is remarkable in that it avoids the use of the String class. Well done.

Note also no use of dynamically allocated memory. You re-use the buffer, but the down side is that the contents of that buffer get altered by the process of decoding.

Another I think important thing about the example is that it is a complete sketch that will run. You can drop it into your IDE, upload it and "Holy Cremona, Batman!" it really does work. I always try to do that when I give people sample code. IntersectionOfCircles is another one of mine. Same thing.

The main point of the way its written, I think, is demonstrating that things like a HTTP request line need to be pulled apart in layers. A common mistake for instance, is to interpret '+' as a space character in the resource part of the uri. That's wrong, because '+'=' ' only pertains to encoding of parameters in html forms. Likewise, you have to pull apart the querystring into its parts before decoding the url percents. All of this kind of internetty stuff is made up of layers of functionality, each with their own specification. Attempting to jam the whole thing into a regex and get stuff out of it never works well - unwrapping it step-by-step does.