Anonymous avatar Anonymous committed cdfb950 Merge

merge in rebar modifications

Comments (0)

Files changed (5)

 14365a12cb1463eba5850c33617480ba2be8e686 webmachine-1.4
 616b08c30b4c29503063f23e9e6329c12feb3e90 webmachine-1.4
 e75bdcf6eb529d44c686fbea20dd305e6f169544 webmachine-1.5
+4fec467ced13e0ef4c995d76c69d301e4eeda829 webmachine-1.6

ebin/webmachine.app

 {application, webmachine,
  [{description, "webmachine"},
-  {vsn, "1.5"},
+  {vsn, "1.6"},
   {modules, [
     webmachine,
     webmachine_app,

src/webmachine_decision_core.erl

 -include("webmachine_logger.hrl").
 
 handle_request(Resource, ReqState) ->
+    [erase(X) || X <- [decision, code, req_body, bytes_written, tmp_reqstate]],
     put(resource, Resource),
     put(reqstate, ReqState),
     try

src/webmachine_request.erl

 -include_lib("include/wm_reqstate.hrl").
 -include_lib("include/wm_reqdata.hrl").
 
--define(WMVSN, "1.5.2").
--define(QUIP, "that tip is the fix").
+-define(WMVSN, "1.6").
+-define(QUIP, "eat around the stinger").
 -define(IDLE_TIMEOUT, infinity).
 
 trim_state() ->
     end.
 
 recv_stream_body(PassedState=#wm_reqstate{reqdata=RD}, MaxHunkSize) ->
+    put(mochiweb_request_recv, true),
     case get_header_value("expect") of
 	{"100-continue", _} ->
 	    send(PassedState#wm_reqstate.socket, 
 		 [make_version(wrq:version(RD)),
-                  make_code(100), <<"\r\n">>]);
+                  make_code(100), <<"\r\n\r\n">>]);
 	_Else ->
 	    ok
     end,
 % @type reqdata(). The opaque data type used for req/resp data structures.
 -include_lib("include/wm_reqdata.hrl").
 -include_lib("include/wm_reqstate.hrl").
+-include_lib("eunit/include/eunit.hrl").
+
 
 create(Method,Version,RawPath,Headers) ->
     create(#wm_reqdata{method=Method,version=Version,
       req_qs=defined_in_create,
       peer="defined_in_wm_req_srv_init",
       req_body=not_fetched_yet,
-      max_recv_body=(50*(1024*1024)),
+      max_recv_body=(1024*(1024*1024)),
       app_root="defined_in_load_dispatch_data",
       path_info=dict:new(),
       path_tokens=defined_in_load_dispatch_data,
 get_qs_value(Key, Default, RD) when is_list(Key) ->
     proplists:get_value(Key, req_qs(RD), Default).
 
+make_wrq(Method, RawPath, Headers) ->
+    create(Method, {1,1}, RawPath, mochiweb_headers:from_list(Headers)).
 
+accessor_test() ->
+    R0 = make_wrq('GET', "/foo?a=1&b=2", [{"Cookie", "foo=bar"}]),
+    R = set_peer("127.0.0.1", R0),
+    ?assertEqual('GET', method(R)),
+    ?assertEqual({1,1}, version(R)),
+    ?assertEqual("/foo", path(R)),
+    ?assertEqual("/foo?a=1&b=2", raw_path(R)),     
+    ?assertEqual([{"a", "1"}, {"b", "2"}], req_qs(R)),
+    ?assertEqual({"1", "2"}, {get_qs_value("a", R), get_qs_value("b", R)}),
+    ?assertEqual("3", get_qs_value("c", "3", R)),
+    ?assertEqual([{"foo", "bar"}], req_cookie(R)),
+    ?assertEqual("bar", get_cookie_value("foo", R)),
+    ?assertEqual("127.0.0.1", peer(R)).
+
+    
+simple_dispatch_test() ->
+    R0 = make_wrq('GET', "/foo?a=1&b=2", [{"Cookie", "foo=bar"}]),
+    R1 = set_peer("127.0.0.1", R0),    
+    {_, _, HostTokens, Port, PathTokens, Bindings, AppRoot, StringPath} = 
+        webmachine_dispatcher:dispatch("127.0.0.1", "/foo", 
+                                       [{["foo"], foo_resource, []}]),
+    R = load_dispatch_data(Bindings,
+                           HostTokens,
+                           Port,
+                           PathTokens,
+                           AppRoot,
+                           StringPath,
+                           R1),
+    ?assertEqual(".", app_root(R)),
+    ?assertEqual(80, port(R)).
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.