diff --git a/doc/reading_headers.rst b/doc/reading_headers.rst new file mode 100644 index 0000000..55ce5c9 --- /dev/null +++ b/doc/reading_headers.rst @@ -0,0 +1,13 @@ +Reading Headers +=============== + +The HTTP protocol allows metadata using headers. + +Kapow! allows you to read them easily: + + +In this example, we read the header ``User-Agent`` and feed it +to the response: +.. code-block:: bash + + kapow get /request/headers/User-Agent | kapow set /response/body diff --git a/doc/redirecting_a_url-BROKEN.rst b/doc/redirecting_a_url-BROKEN.rst new file mode 100644 index 0000000..7409cea --- /dev/null +++ b/doc/redirecting_a_url-BROKEN.rst @@ -0,0 +1,12 @@ +Redirecting a URL +================= + +The HTTP protocol allows queries to a URL to be redirected to other URL. + +We can do them in Kapow! with little effort: + +In this example, we read the header ``User-Agent`` and feed it to the response: +.. code-block:: bash + + echo -n 302 | kapow set /response/status + echo -n http://foobar-url.example | kapow set /response/headers/Location diff --git a/doc/writing_headers.rst b/doc/writing_headers.rst new file mode 100644 index 0000000..470f5c7 --- /dev/null +++ b/doc/writing_headers.rst @@ -0,0 +1,18 @@ +Writing Headers +=============== + +The HTTP protocol allows metadata using headers. + +Kapow! allows you to set them easily: + + +In this example, we respond by setting the ``Content-Type`` header +to the value ``application/json``. +.. code-block:: bash + + kapow set /response/headers/Content-Type application/json + +We could then return some JSON content: +.. code-block:: bash + + echo '{"data": "some relevant string"}' | kapow set /response/body