summaryrefslogtreecommitdiff
path: root/src/couch_inets/httpd_esi.erl
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2008-04-15 12:21:00 +0000
committerChristopher Lenz <cmlenz@apache.org>2008-04-15 12:21:00 +0000
commit39de3072bcf9fdeec6d3faeb125924c401242205 (patch)
treeda55307c8762f9ff16f7a7e478d971c0f352d281 /src/couch_inets/httpd_esi.erl
parent53968ddfd93bfe1aa403478de715ae0ac77db177 (diff)
Merged mochiweb branch back into trunk.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@648222 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couch_inets/httpd_esi.erl')
-rw-r--r--src/couch_inets/httpd_esi.erl106
1 files changed, 0 insertions, 106 deletions
diff --git a/src/couch_inets/httpd_esi.erl b/src/couch_inets/httpd_esi.erl
deleted file mode 100644
index 2f7c9d38..00000000
--- a/src/couch_inets/httpd_esi.erl
+++ /dev/null
@@ -1,106 +0,0 @@
-%% ``The contents of this file are subject to the Erlang Public License,
-%% Version 1.1, (the "License"); you may not use this file except in
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved via the world wide web at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
-%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
-%% AB. All Rights Reserved.''
-%%
-%% $Id$
-%%
--module(httpd_esi).
-
--export([parse_headers/1, handle_headers/1]).
-
--include("inets_internal.hrl").
-
-%%%=========================================================================
-%%% Internal application API
-%%%=========================================================================
-
-%%--------------------------------------------------------------------------
-%% parse_headers(Data) -> {Headers, Body}
-%%
-%% Data = string() | io_list()
-%% Headers = string()
-%% Body = io_list()
-%%
-%% Description: Parses <Data> and divides it to a header part and a
-%% body part. Note that it is presumed that <Data> starts with a
-%% string including "\r\n\r\n" if there is any header information
-%% present. The returned headers will not contain the HTTP header body
-%% delimiter \r\n. (All header, header delimiters are keept.)
-%% Ex: ["Content-Type : text/html\r\n Connection : closing \r\n\r\n" |
-%% io_list()] --> {"Content-Type : text/html\r\n Connection : closing \r\n",
-%% io_list()}
-%%--------------------------------------------------------------------------
-parse_headers(Data) ->
- parse_headers(Data, []).
-
-%%--------------------------------------------------------------------------
-%% handle_headers(Headers) -> {ok, HTTPHeaders, StatusCode} |
-%% {proceed, AbsPath}
-%% Headers = string()
-%% HTTPHeaders = [{HeaderField, HeaderValue}]
-%% HeaderField = string()
-%% HeaderValue = string()
-%% StatusCode = integer()
-%%
-%% Description: Transforms the plain HTTP header string data received
-%% from the ESI program into a list of header values and an
-%% appropriate HTTP status code. Note if a location header is present
-%% the return value will be {proceed, AbsPath}
-%%--------------------------------------------------------------------------
-handle_headers("") ->
- {ok, [], 200};
-handle_headers(Headers) ->
- NewHeaders = string:tokens(Headers, ?CRLF),
- handle_headers(NewHeaders, [], 200).
-
-%%%========================================================================
-%%% Internal functions
-%%%========================================================================
-parse_headers([], Acc) ->
- {[], lists:reverse(Acc)};
-parse_headers([?CR, ?LF, ?CR, ?LF], Acc) ->
- {lists:reverse(Acc) ++ [?CR, ?LF], []};
-parse_headers([?CR, ?LF, ?CR, ?LF | Rest], Acc) ->
- {lists:reverse(Acc) ++ [?CR, ?LF], Rest};
-parse_headers([Char | Rest], Acc) ->
- parse_headers(Rest, [Char | Acc]).
-
-handle_headers([], NewHeaders, StatusCode) ->
- {ok, NewHeaders, StatusCode};
-
-handle_headers([Header | Headers], NewHeaders, StatusCode) ->
- {FieldName, FieldValue} = httpd_response:split_header(Header, []),
- case FieldName of
- "location" ->
- case http_request:is_absolut_uri(FieldValue) of
- true ->
- handle_headers(Headers,
- [{FieldName, FieldValue} | NewHeaders],
- 302);
- false ->
- {proceed, FieldValue}
- end;
- "status" ->
- NewStatusCode =
- case httpd_util:split(FieldValue," ",2) of
- {ok,[Code,_]} ->
- list_to_integer(Code);
- _ ->
- 200
- end,
- handle_headers(Headers, NewHeaders, NewStatusCode);
- _ ->
- handle_headers(Headers,
- [{FieldName, FieldValue}| NewHeaders], StatusCode)
- end.