Skip to content
Browse files

Add MIT License information.

  • Loading branch information...
1 parent 951cc9d commit 3bbab7458d0aa9f94767cd359c7d3f7154f25f72 @rustyio rustyio committed May 16, 2009
View
19 MIT-LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2008-2009 Rusty Klophaus
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
15 data/inets_request_data
@@ -1,15 +0,0 @@
-{mod,{init_data,{53030,"127.0.0.1"},"rklophaus-mac2"},
- [],ip_comm,socket,httpd_conf__0_0_0_0__8000,"GET",
- "localhost:8000/web/req?querystring","/web/req?querystring","HTTP/1.1",
- "GET /web/req?querystring HTTP/1.1",
- [{"connection","keep-alive"},
- {"keep-alive","300"},
- {"accept-charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7"},
- {"accept-encoding","gzip,deflate"},
- {"accept-language","en-us,en;q=0.5"},
- {"accept",
- "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},
- {"user-agent",
- "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10"},
- {"host","localhost:8000"}],
- [],true}.
View
26 data/mochiweb_request_data
@@ -1,26 +0,0 @@
-{mochiweb_request,socket,'GET',"/web/req",
- {1,1},
- {9,
- {"host",
- {'Host',"localhost:8000"},
- {"accept",
- {'Accept',"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},
- nil,
- {"accept-language",
- {'Accept-Language',"en-us,en;q=0.5"},
- {"accept-encoding",
- {'Accept-Encoding',"gzip,deflate"},
- {"accept-charset",
- {'Accept-Charset',"ISO-8859-1,utf-8;q=0.7,*;q=0.7"},
- nil,nil},
- nil},
- {"connection",
- {'Connection',"keep-alive"},
- nil,
- {"cookie",
- {'Cookie',"wf=W-AaB4NQAAAAUHicy2DKY2XQ9606zJfBlJ7CIJSXWVKUn56a52BoZK5nAISGDAzMBxmAgKmIgRmrAiYGhrmLGaAAAB_nEZU"},
- nil,nil}}}},
- {"user-agent",
- {'User-Agent',"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10"},
- {"keep-alive",{'Keep-Alive',"300"},nil,nil},
- nil}}}}.
View
19 data/yaws_request_data
@@ -1,19 +0,0 @@
-{arg,socket,
- {{127,0,0,1},52490},
- {headers,"keep-alive",
- "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
- "localhost:8000",undefined,undefined,undefined,undefined,
- undefined,undefined,undefined,
- "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10",
- undefined,
- ["wf=lcKwlYNQAAAAUHicy2DKY2X46V91mC-DKT2FQSgvs6QoPz01z8HQyFzPAAgNGRiYFzMAAXMRAzNWBcwMDHOTGKAAAFSJEgQ"],
- "300",undefined,undefined,undefined,undefined,undefined,
- undefined,
- [{http_header,1,'Cache-Control',undefined,"max-age=0"},
- {http_header,9,'Accept-Charset',undefined,
- "ISO-8859-1,utf-8;q=0.7,*;q=0.7"},
- {http_header,10,'Accept-Encoding',undefined,"gzip,deflate"},
- {http_header,11,'Accept-Language',undefined,"en-us,en;q=0.5"}]},
- {http_request,'GET',{abs_path,"/web/req"},{1,1}},
- undefined,"/web/req",undefined,"req","./wwwroot","/","./wwwroot/web/req",
- undefined,undefined,<0.934.0>,[],"/","/","/req"}.
View
3 include/simplebridge.inc
@@ -1,3 +0,0 @@
--record(response, { statuscode=200, headers=[], cookies=[], data=[] }).
--record(cookie, { name, value, path="/", minutes_to_live=20 }).
--record(header, { name, value }).
View
4 src/inets_bridge_modules/inets_response_bridge.erl
@@ -1,3 +1,7 @@
+% Simple Bridge
+% Copyright (c) 2008-2009 Rusty Klophaus
+% See MIT-LICENSE for licensing information.
+
-module (inets_response_bridge).
-behaviour (response_bridge).
-include ("simplebridge.hrl").
View
46 src/platforms/inets_request_bridge.erl
@@ -1,46 +0,0 @@
-% Simple Bridge
-% Copyright (c) 2008-2009 Rusty Klophaus
-% See MIT-LICENSE for licensing information.
-
--module (inets_request_bridge).
--behaviour (request_bridge).
--include ("httpd_r12b5.hrl").
--export ([
- init/1,
- request_method/1, path/1, querystring/1,
- peer_ip/1, peer_port/1
-]).
-
-
--define(PRINT(Var), error_logger:info_msg("DEBUG: ~p:~p - ~p: ~p~n", [?MODULE, ?LINE, ??Var, Var])).
-
-init(Req) ->
- Req.
-
-request_method(Req) ->
- list_to_atom(Req#mod.method).
-
-path(Req) ->
- {Path, _QueryString} = split_request_uri(Req#mod.request_uri, []),
- Path.
-
-querystring(Req) ->
- {_Path, QueryString} = split_request_uri(Req#mod.request_uri, []),
- QueryString.
-
-peer_ip(Req) ->
- Socket = Req#mod.socket,
- {ok, {IP, _Port}} = inet:peername(Socket),
- IP.
-
-peer_port(Req) ->
- Socket = Req#mod.socket,
- {ok, {_IP, Port}} = inet:peername(Socket),
- Port.
-
-
-
-split_request_uri([], Path) -> {lists:reverse(Path), ""};
-split_request_uri([$?|QueryString], Path) -> {lists:reverse(Path), QueryString};
-split_request_uri([H|T], Path) -> split_request_uri(T,[H|Path]).
-
View
45 src/platforms/mochiweb_request_bridge.erl.txt
@@ -1,45 +0,0 @@
-% Simple Bridge
-% Copyright (c) 2008-2009 Rusty Klophaus
-% See MIT-LICENSE for licensing information.
-
--module (mochiweb_request_bridge).
--behaviour (request_bridge).
--export ([
- init/1,
- request_method/1, url/1, protocol/1, hostname/1, port/1, path/1, querystring/1,
- peer_ip/1, peer_port/1
-]).
-
-
-init(Req) ->
- Req.
-
-request_method(Req) ->
- Req:get(method).
-
-url(_Req) ->
- ok.
-
-protocol(_Req) ->
- ok.
-
-hostname(_Req) ->
- ok.
-
-port(_Req) ->
- ok.
-
-path(_Req) ->
- ok.
-
-querystring(Req) ->
- Req = wf_platform:get_request(),
- RawPath = Req:get(raw_path),
- {_, QueryString, _} = mochiweb_util:urlsplit_path(RawPath),
- QueryString.
-
-peer_ip(_Req) ->
- ok.
-
-peer_port(_Req) ->
- ok.
View
144 src/platforms/yaws_request_bridge.erl.txt
@@ -1,144 +0,0 @@
-% Simple Bridge
-% Copyright (c) 2008-2009 Rusty Klophaus
-% See MIT-LICENSE for licensing information.
-
--module (wf_platform_yaws).
--include ("yaws_api.hrl").
--export ([
- get_platform/0,
-
- get_raw_path/0,
- get_querystring/0,
- get_request_method/0,
- get_request_body/0,
-
- parse_get_args/0,
- parse_post_args/0,
-
- get_cookie/1,
- create_cookie/4,
-
- create_header/2,
- get_headers/0,
- get_header/1,
-
- build_response/0,
-
- get_socket/0,
- recv_from_socket/2
-]).
-
-get_platform() -> yaws.
-
-%%% PATH, METHOD, AND ARGS %%%
-
-get_raw_path() ->
- Arg = wf_platform:get_request(),
- wf:f("~s?~s", [Arg#arg.server_path, wf:to_list(Arg#arg.querydata)]).
-
-get_querystring() ->
- Arg = wf_platform:get_request(),
- Arg#arg.querydata.
-
-get_request_method() ->
- Arg = wf_platform:get_request(),
- (Arg#arg.req)#http_request.method.
-
-get_request_body() ->
- Arg = wf_platform:get_request(),
- case Arg#arg.clidata of
- {partial, Data} -> Data;
- Data -> Data
- end.
-
-parse_get_args() ->
- Arg = wf_platform:get_request(),
- yaws_api:parse_query(Arg).
-
-parse_post_args() ->
- Arg = wf_platform:get_request(),
- yaws_api:parse_post(Arg).
-
-
-
-%%% COOKIES %%%
-
-get_cookie(Key) ->
- Arg = wf_platform:get_request(),
- Key1 = wf:to_list(Key),
- Headers = Arg#arg.headers,
- yaws_api:find_cookie_val(Key1, Headers#headers.cookie).
-
-create_cookie(Key, Value, Path, MinutesToLive) ->
- SecondsToLive = MinutesToLive * 60,
- Expire = to_cookie_expire(SecondsToLive),
- yaws_api:setcookie(Key, Value, Path, Expire).
-
-to_cookie_expire(SecondsToLive) ->
- Seconds = calendar:datetime_to_gregorian_seconds(calendar:local_time()),
- DateTime = calendar:gregorian_seconds_to_datetime(Seconds + SecondsToLive),
- httpd_util:rfc1123_date(DateTime).
-
-
-
-%%% HEADERS %%%
-
-create_header(Key, Value) ->
- {header, {Key, Value}}.
-
-get_headers() ->
- Arg = wf_platform:get_request(),
- Headers = Arg#arg.headers,
- [
- {connection, Headers#headers.connection},
- {accept, Headers#headers.accept},
- {host, Headers#headers.host},
- {if_modified_since, Headers#headers.if_modified_since},
- {if_match, Headers#headers.if_match},
- {if_none_match, Headers#headers.if_range},
- {if_unmodified_since, Headers#headers.if_unmodified_since},
- {range, Headers#headers.range},
- {referer, Headers#headers.referer},
- {user_agent, Headers#headers.user_agent},
- {accept_ranges, Headers#headers.accept_ranges},
- {cookie, Headers#headers.cookie},
- {keep_alive, Headers#headers.keep_alive},
- {location, Headers#headers.location},
- {content_length, Headers#headers.content_length},
- {content_type, Headers#headers.content_type},
- {content_encoding, Headers#headers.content_encoding},
- {authorization, Headers#headers.authorization},
- {transfer_encoding, Headers#headers.transfer_encoding}
- ].
-
-get_header(Header) ->
- Headers = get_headers(),
- proplists:get_value(Header, Headers).
-
-%%% RESPONSE %%%
-
-build_response() ->
- % Get vars...
- ContentType = get(wf_content_type),
- Body = get(wf_response_body),
-
- % Send the yaws response...
- lists:flatten([
- {status, get(wf_response_code)},
- get(wf_headers),
- {content, ContentType, Body}
- ]).
-
-
-%%% SOCKETS %%%
-
-get_socket() ->
- Arg = wf_platform:get_request(),
- Arg#arg.clisock.
-
-recv_from_socket(Length, Timeout) ->
- Socket = get_socket(),
- case gen_tcp:recv(Socket, Length, Timeout) of
- {ok, Data} -> Data;
- _ -> exit(normal)
- end.
View
2 src/request_bridge.erl
@@ -1,4 +1,4 @@
-% Simple Erlang Web Bridge
+% Simple Bridge
% Copyright (c) 2008-2009 Rusty Klophaus
% See MIT-LICENSE for licensing information.
View
2 src/request_bridge_wrapper.erl
@@ -1,4 +1,4 @@
-% Simple Erlang Web Bridge
+% Simple Bridge
% Copyright (c) 2008-2009 Rusty Klophaus
% See MIT-LICENSE for licensing information.
View
3 src/response_bridge.erl
@@ -1,8 +1,7 @@
-% Simple Erlang Web Bridge
+% Simple Bridge
% Copyright (c) 2008-2009 Rusty Klophaus
% See MIT-LICENSE for licensing information.
-
-module (response_bridge).
-include ("simplebridge.hrl").
-export ([
View
2 src/response_bridge_wrapper.erl
@@ -1,4 +1,4 @@
-% Simple Erlang Web Bridge
+% Simple Bridge
% Copyright (c) 2008-2009 Rusty Klophaus
% See MIT-LICENSE for licensing information.

0 comments on commit 3bbab74

Please sign in to comment.
Something went wrong with that request. Please try again.