This commit adds support for response cookies. Response now has a method
cookie to fetch the current cookie. One cookie has multiple crumbs which
represent a key value pair. For each crumb multiple options can be set
according to the specs.
This change sorts the routes to get the most specific routes first and
avoid hitting a route which is not the most specific match.
With this the regex to extract variables is made more strict to avoid
matching half of the URI.
Browsers are not able to send put, delete or any other request from a
plain html form. This limits the possibilities with APIs so an override
was introduced in many frameworks in the form, that `_method` could be
defined in a post payload.
With this, zero also supports `_method` in the post payload to make it
possible to use all functions of the API with javascript through plain
html.
This fixes a bug where a charset in the content type blocked the
extraction of the payload.
A browser may send a string like
multipart/form-data; charset=UTF-8
which include? could not find the defined types. Now it gets split and
then checked against the defined types.
This extends the server class with the information, if it is serving
http or https. This can then be used to generate a root uri to the web
application.
The renderer is now a bit smaller and asks the TemplateFinder for the
actual resources. That way it can just concentrate on rendering instead
of finding out, which stuff actually exists and which not.
The template finder is now the instance to ask for templates. It was
already looking for them, so it should be able to handle questions
regarding the existence of templates too.
This step is a preparation to extend the functionality of the renderer.
To make the main class easier, the search for templates and building of
the tree is extracted into its own class.
This makes the assignment for bodies easier when using plain Strings.
They get wrapped in an array as per rack definition.
For every other type, they have to implement each and get directly set
as body or have to be rendered to Strings first.
Fix tests for PATCH, because spec_helper didn't support it and the tests where
wrong.
Remove if statement from "conent_type", because ruby already returns nil, if the
requested key in a hash is not found. (Sounds a bit ugly, but it's true.)
Killed 13 of 14 mutants. I will see later, how it's possible to kill the last
one.
I also fixed the return value of "preferred", if the in initialize given string
is empty. Fixed the default value here.
To make the router more loose, I replaced the router with the plain
environment. The custom parameters are stored in the same key, so can be
used by the request later.
Plus some specs.
This should it make later possible to make Zero work with Ruby 1.8. But
at the moment it only routes to the original decode_www_form method, if
it exists. Otherwise it returns an empty Array. So this will still fail
on the 1.8 versions at the moment.
The splitting of rendering and processing is good, but on the other side
it makes some double steps or even introduce workarounds.
That is why I made the method #render just a call to the renderer. This
should help much more than the strict seperation.
The method will only return the resulting string and not add it to the
body of the response. That still has to be taken care of by the user.
This avoids hardcoding the options into the controller and therefore
should it make possible to use Rack::Request or Sinatra apps as
requests. (That sounds so weird.)