1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-23 00:00:06 +01:00
libwebsockets/doc/latex/group__HTTP-headers-create.tex
Andy Green 014481e912 documentation convert to doxygen
Signed-off-by: Andy Green <andy@warmcat.com>
2016-07-14 08:57:27 +08:00

172 lines
No EOL
12 KiB
TeX

\hypertarget{group__HTTP-headers-create}{}\section{H\+T\+TP headers\+: create}
\label{group__HTTP-headers-create}\index{H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item
L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT \hyperlink{group__HTTP-headers-create_ga29b7d6d2ddfdbaff3d8b607e7e3151b6}{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+status} (struct lws $\ast$wsi, unsigned int code, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)
\item
L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT \hyperlink{group__HTTP-headers-create_ga2b36bf44405755ff51c1939303b995a8}{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+name} (struct lws $\ast$wsi, const unsigned char $\ast$name, const unsigned char $\ast$value, int length, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)
\item
L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT \hyperlink{group__HTTP-headers-create_gaf74adb761b22566ad70004882712dce1}{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+token} (struct lws $\ast$wsi, enum lws\+\_\+token\+\_\+indexes token, const unsigned char $\ast$value, int length, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)
\item
L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT \hyperlink{group__HTTP-headers-create_gacc76a5babcb4dce1b01b1955aa7a2faf}{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+content\+\_\+length} (struct lws $\ast$wsi, unsigned long content\+\_\+length, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)
\item
L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT \hyperlink{group__HTTP-headers-create_ga4887605ff2242a54db3a7fa01f6f864b}{lws\+\_\+finalize\+\_\+http\+\_\+header} (struct lws $\ast$wsi, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)
\end{DoxyCompactItemize}
\subsection{Detailed Description}
\subsubsection*{H\+T\+TP headers\+: Create}
These apis allow you to create H\+T\+TP response headers in a way compatible with both H\+T\+T\+P/1.\+x and H\+T\+T\+P/2.
They each append to a buffer taking care about the buffer end, which is passed in as a pointer. When data is written to the buffer, the current position p is updated accordingly.
All of these apis are L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT as they can run out of space and fail with nonzero return.
\subsection{Function Documentation}
\index{H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}!lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+name@{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+name}}
\index{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+name@{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+name}!H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}}
\subsubsection[{\texorpdfstring{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+name(struct lws $\ast$wsi, const unsigned char $\ast$name, const unsigned char $\ast$value, int length, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)}{lws\_add\_http\_header\_by\_name(struct lws *wsi, const unsigned char *name, const unsigned char *value, int length, unsigned char **p, unsigned char *end)}}]{\setlength{\rightskip}{0pt plus 5cm}L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+name (
\begin{DoxyParamCaption}
\item[{struct lws $\ast$}]{wsi, }
\item[{const unsigned char $\ast$}]{name, }
\item[{const unsigned char $\ast$}]{value, }
\item[{int}]{length, }
\item[{unsigned char $\ast$$\ast$}]{p, }
\item[{unsigned char $\ast$}]{end}
\end{DoxyParamCaption}
)}\hypertarget{group__HTTP-headers-create_ga2b36bf44405755ff51c1939303b995a8}{}\label{group__HTTP-headers-create_ga2b36bf44405755ff51c1939303b995a8}
{\ttfamily \#include $<$\hyperlink{libwebsockets_8h}{lib/libwebsockets.\+h}$>$}
\hyperlink{group__HTTP-headers-create_ga2b36bf44405755ff51c1939303b995a8}{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+name()} -\/ append named header and value
\begin{DoxyParams}{Parameters}
{\em wsi} & the connection to check \\
\hline
{\em name} & the hdr name, like \char`\"{}my-\/header\char`\"{} \\
\hline
{\em value} & the value after the = for this header \\
\hline
{\em length} & the length of the value \\
\hline
{\em p} & pointer to current position in buffer pointer \\
\hline
{\em end} & pointer to end of buffer\\
\hline
\end{DoxyParams}
Appends name\+: value to the headers \index{H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}!lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+token@{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+token}}
\index{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+token@{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+token}!H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}}
\subsubsection[{\texorpdfstring{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+token(struct lws $\ast$wsi, enum lws\+\_\+token\+\_\+indexes token, const unsigned char $\ast$value, int length, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)}{lws\_add\_http\_header\_by\_token(struct lws *wsi, enum lws\_token\_indexes token, const unsigned char *value, int length, unsigned char **p, unsigned char *end)}}]{\setlength{\rightskip}{0pt plus 5cm}L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+token (
\begin{DoxyParamCaption}
\item[{struct lws $\ast$}]{wsi, }
\item[{enum lws\+\_\+token\+\_\+indexes}]{token, }
\item[{const unsigned char $\ast$}]{value, }
\item[{int}]{length, }
\item[{unsigned char $\ast$$\ast$}]{p, }
\item[{unsigned char $\ast$}]{end}
\end{DoxyParamCaption}
)}\hypertarget{group__HTTP-headers-create_gaf74adb761b22566ad70004882712dce1}{}\label{group__HTTP-headers-create_gaf74adb761b22566ad70004882712dce1}
{\ttfamily \#include $<$\hyperlink{libwebsockets_8h}{lib/libwebsockets.\+h}$>$}
\hyperlink{group__HTTP-headers-create_gaf74adb761b22566ad70004882712dce1}{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+token()} -\/ append given header and value
\begin{DoxyParams}{Parameters}
{\em wsi} & the connection to check \\
\hline
{\em token} & the token index for the hdr \\
\hline
{\em value} & the value after the = for this header \\
\hline
{\em length} & the length of the value \\
\hline
{\em p} & pointer to current position in buffer pointer \\
\hline
{\em end} & pointer to end of buffer\\
\hline
\end{DoxyParams}
Appends name=value to the headers, but is able to take advantage of better H\+T\+T\+P/2 coding mechanisms where possible. \index{H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}!lws\+\_\+add\+\_\+http\+\_\+header\+\_\+content\+\_\+length@{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+content\+\_\+length}}
\index{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+content\+\_\+length@{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+content\+\_\+length}!H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}}
\subsubsection[{\texorpdfstring{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+content\+\_\+length(struct lws $\ast$wsi, unsigned long content\+\_\+length, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)}{lws\_add\_http\_header\_content\_length(struct lws *wsi, unsigned long content\_length, unsigned char **p, unsigned char *end)}}]{\setlength{\rightskip}{0pt plus 5cm}L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT lws\+\_\+add\+\_\+http\+\_\+header\+\_\+content\+\_\+length (
\begin{DoxyParamCaption}
\item[{struct lws $\ast$}]{wsi, }
\item[{unsigned long}]{content\+\_\+length, }
\item[{unsigned char $\ast$$\ast$}]{p, }
\item[{unsigned char $\ast$}]{end}
\end{DoxyParamCaption}
)}\hypertarget{group__HTTP-headers-create_gacc76a5babcb4dce1b01b1955aa7a2faf}{}\label{group__HTTP-headers-create_gacc76a5babcb4dce1b01b1955aa7a2faf}
{\ttfamily \#include $<$\hyperlink{libwebsockets_8h}{lib/libwebsockets.\+h}$>$}
\hyperlink{group__HTTP-headers-create_ga2b36bf44405755ff51c1939303b995a8}{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+by\+\_\+name()} -\/ append content-\/length helper
\begin{DoxyParams}{Parameters}
{\em wsi} & the connection to check \\
\hline
{\em content\+\_\+length} & the content length to use \\
\hline
{\em p} & pointer to current position in buffer pointer \\
\hline
{\em end} & pointer to end of buffer\\
\hline
\end{DoxyParams}
Appends content-\/length\+: content\+\_\+length to the headers \index{H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}!lws\+\_\+add\+\_\+http\+\_\+header\+\_\+status@{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+status}}
\index{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+status@{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+status}!H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}}
\subsubsection[{\texorpdfstring{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+status(struct lws $\ast$wsi, unsigned int code, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)}{lws\_add\_http\_header\_status(struct lws *wsi, unsigned int code, unsigned char **p, unsigned char *end)}}]{\setlength{\rightskip}{0pt plus 5cm}L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT lws\+\_\+add\+\_\+http\+\_\+header\+\_\+status (
\begin{DoxyParamCaption}
\item[{struct lws $\ast$}]{wsi, }
\item[{unsigned int}]{code, }
\item[{unsigned char $\ast$$\ast$}]{p, }
\item[{unsigned char $\ast$}]{end}
\end{DoxyParamCaption}
)}\hypertarget{group__HTTP-headers-create_ga29b7d6d2ddfdbaff3d8b607e7e3151b6}{}\label{group__HTTP-headers-create_ga29b7d6d2ddfdbaff3d8b607e7e3151b6}
{\ttfamily \#include $<$\hyperlink{libwebsockets_8h}{lib/libwebsockets.\+h}$>$}
\hyperlink{group__HTTP-headers-create_ga29b7d6d2ddfdbaff3d8b607e7e3151b6}{lws\+\_\+add\+\_\+http\+\_\+header\+\_\+status()} -\/ add the H\+T\+TP response status code
\begin{DoxyParams}{Parameters}
{\em wsi} & the connection to check \\
\hline
{\em code} & an H\+T\+TP code like 200, 404 etc (see enum http\+\_\+status) \\
\hline
{\em p} & pointer to current position in buffer pointer \\
\hline
{\em end} & pointer to end of buffer\\
\hline
\end{DoxyParams}
Adds the initial response code, so should be called first \index{H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}!lws\+\_\+finalize\+\_\+http\+\_\+header@{lws\+\_\+finalize\+\_\+http\+\_\+header}}
\index{lws\+\_\+finalize\+\_\+http\+\_\+header@{lws\+\_\+finalize\+\_\+http\+\_\+header}!H\+T\+T\+P headers\+: create@{H\+T\+T\+P headers\+: create}}
\subsubsection[{\texorpdfstring{lws\+\_\+finalize\+\_\+http\+\_\+header(struct lws $\ast$wsi, unsigned char $\ast$$\ast$p, unsigned char $\ast$end)}{lws\_finalize\_http\_header(struct lws *wsi, unsigned char **p, unsigned char *end)}}]{\setlength{\rightskip}{0pt plus 5cm}L\+W\+S\+\_\+\+V\+I\+S\+I\+B\+LE L\+W\+S\+\_\+\+E\+X\+T\+E\+RN int L\+W\+S\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT lws\+\_\+finalize\+\_\+http\+\_\+header (
\begin{DoxyParamCaption}
\item[{struct lws $\ast$}]{wsi, }
\item[{unsigned char $\ast$$\ast$}]{p, }
\item[{unsigned char $\ast$}]{end}
\end{DoxyParamCaption}
)}\hypertarget{group__HTTP-headers-create_ga4887605ff2242a54db3a7fa01f6f864b}{}\label{group__HTTP-headers-create_ga4887605ff2242a54db3a7fa01f6f864b}
{\ttfamily \#include $<$\hyperlink{libwebsockets_8h}{lib/libwebsockets.\+h}$>$}
\hyperlink{group__HTTP-headers-create_ga4887605ff2242a54db3a7fa01f6f864b}{lws\+\_\+finalize\+\_\+http\+\_\+header()} -\/ terminate header block
\begin{DoxyParams}{Parameters}
{\em wsi} & the connection to check \\
\hline
{\em p} & pointer to current position in buffer pointer \\
\hline
{\em end} & pointer to end of buffer\\
\hline
\end{DoxyParams}
Indicates no more headers will be added