summaryrefslogtreecommitdiff
path: root/src/libtipidee/tipidee_response_status.c
blob: 3c8977a1b9083e5e2b2ab42dc74ba94955d0d071 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* ISC license. */

#include <skalibs/types.h>
#include <skalibs/buffer.h>

#include <tipidee/response.h>

size_t tipidee_response_status (buffer *b, tipidee_rql const *rql, unsigned int status, char const *reason)
{
  size_t n = 0 ;
  char fmt[UINT_FMT] ;
  n += buffer_putnoflush(b, "HTTP/", 5) ;
  n += buffer_putnoflush(b, fmt, uint_fmt(fmt, rql->http_major ? rql->http_major : 1)) ;
  n += buffer_putnoflush(b, ".", 1) ;
  n += buffer_putnoflush(b, fmt, uint_fmt(fmt, rql->http_major ? rql->http_minor : 1)) ;
  n += buffer_putnoflush(b, " ", 1) ;
  n += buffer_putnoflush(b, fmt, uint_fmt(fmt, status)) ;
  n += buffer_putnoflush(b, " ", 1) ;
  n += buffer_putsnoflush(b, reason) ;
  n += buffer_putnoflush(b, "\r\n", 2) ;
  return n ;
}