1 .\" Copyright (c) 2021, 2022, 2023
2 .\" Ariston Lorenzo <me@ariston.dev>. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the copyright holder nor the names of its
13 .\" contributors may be used to endorse or promote products derived from
14 .\" this software without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
17 .\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 SetHeader \- Set a specific HTTP header upon a HTTP request.
37 .Vt Link::Server server;
39 server.Get(path, [](Link::Request* req, Link::Response* res) {
40 res->SetHeader(key, value);
45 is a function that sets a specific HTTP header upon a HTTP request. This
46 function is useful for setting headers such as Content-Type, Content-Length,
47 and others. This function is also useful for setting custom headers.
49 The function takes two arguments, the first argument is the key of the header
50 and the second argument is the value of the header. The key and value are
51 both strings. An example of both arguments are "Content-Type" and "text/html".
54 .\" TODO: Add more keys and figure out how to make this a table.
55 This section lists the keys and it's respective values that can be used with.
56 .Bl -tag -width ".Dv Content-Type"
58 The value of this key is the MIME type of the response. The value of this key
59 is a string. An example of the value is "text/html".
61 The value of this key is the length of the response. The value of this key is
62 a string. An example of the value is "1024".
67 returns no value. You can check if the function has failed by checking the
68 HTTP headers when accessing the URL path listed in the server.Get function.
73 No known bugs. Report bugs to "~aristonl/link-discuss@lists.sr.ht".