Skip to content

Commit

Permalink
Fix #352: add special treatment for accept_ranges
Browse files Browse the repository at this point in the history
Add special treatment for the atom accept_ranges in output header
specifications for setting the standard "Accept-Ranges" header. Add
accept_ranges to the documentation.
  • Loading branch information
vinoski committed Dec 9, 2018
1 parent 576ba9c commit 62279e7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/yaws.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,7 @@ \section{All out/1 Return Values}
\item \verb+{www_authenticate, What}+ - Sets the \textit{WWW-Authenticate:}
header.
\item \verb+{vary, What}+ - Sets the \textit{Vary:} header.
\item \verb+{accept_ranges, What}+ - Sets the \textit{Accept-Ranges:} header.
\end{itemize}

All other headers must be added using the normal HTTP syntax. Example:
Expand Down
1 change: 1 addition & 0 deletions include/yaws.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@
transfer_encoding,
www_authenticate,
vary,
accept_ranges,
other % misc other headers
}).

Expand Down
5 changes: 5 additions & 0 deletions man/yaws_api.5
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,11 @@ Sets the WWW-Authenticate: header.
Sets the Vary: header.


\fI{accept_ranges, What}\fR

Sets the Accept-Ranges: header.


All other headers must be added using the normal HTTP syntax.
Example:

Expand Down
9 changes: 8 additions & 1 deletion src/yaws.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,11 @@ accumulate_header({vary, What}) ->
accumulate_header({"Vary", What}) ->
accumulate_header({vary, What});

accumulate_header({accept_ranges, What}) ->
put(outh, (get(outh))#outh{accept_ranges = ["Accept-Ranges: ", What, "\r\n"]});
accumulate_header({"Accept-Ranges", What}) ->
accumulate_header({accept_ranges, What});

%% non-special headers (which may be special in a future Yaws version)
accumulate_header({Name, What}) when is_list(Name) ->
H = get(outh),
Expand Down Expand Up @@ -2102,7 +2107,9 @@ erase_header(www_authenticate) ->
erase_header(location) ->
put(outh, (get(outh))#outh{location=undefined});
erase_header(vary) ->
put(outh, (get(outh))#outh{vary=undefined}).
put(outh, (get(outh))#outh{vary=undefined});
erase_header(accept_ranges) ->
put(outh, (get(outh))#outh{accept_ranges=undefined}).

getuid() ->
case os:type() of
Expand Down

0 comments on commit 62279e7

Please sign in to comment.