diff --git a/contrib/ise_library/cURL b/contrib/ise_library/cURL index ad2a498f..2b7043f6 160000 --- a/contrib/ise_library/cURL +++ b/contrib/ise_library/cURL @@ -1 +1 @@ -Subproject commit ad2a498fc067926713ffdc0a9db99358f142fada +Subproject commit 2b7043f670f6efc70ebed5fbf62d83a22c095ffe diff --git a/examples/restbucksCRUD/client/src/restbuck_client.e b/examples/restbucksCRUD/client/src/restbuck_client.e index 8dd1fa76..2b2430dc 100644 --- a/examples/restbucksCRUD/client/src/restbuck_client.e +++ b/examples/restbucksCRUD/client/src/restbuck_client.e @@ -23,17 +23,19 @@ feature {NONE} -- Initialization do create h.make sess := h.new_session ("http://127.0.0.1:9090") + -- Create Order print ("%N Create Order %N") resp := create_order (sess) + -- Read the Order print ("%N Read Order %N") l_location := resp.header ("Location") resp := read_order (sess, l_location) - -- Update the Order + -- Update the Order if attached resp.body as l_body then body := l_body.as_string_8 body.replace_substring_all ("takeAway", "in Shop") @@ -43,11 +45,15 @@ feature {NONE} -- Initialization end update_order ( sess: HTTP_CLIENT_SESSION; uri : detachable READABLE_STRING_8; a_body : STRING) : HTTP_CLIENT_RESPONSE + local + context : HTTP_CLIENT_REQUEST_CONTEXT do create Result.make if attached uri as l_uri then sess.set_base_url (l_uri) - Result := sess.put ("", Void, a_body ) + create context.make + context.headers.put ("application/json", "Content-Type") + Result := sess.put ("", context, a_body ) -- Show headers across Result.headers as l_headers diff --git a/examples/restbucksCRUD/src/resource/order_handler.e b/examples/restbucksCRUD/src/resource/order_handler.e index 5dff276a..dba573fe 100644 --- a/examples/restbucksCRUD/src/resource/order_handler.e +++ b/examples/restbucksCRUD/src/resource/order_handler.e @@ -114,8 +114,7 @@ feature -- HTTP Methods do if attached req.orig_path_info as orig_path then id := get_order_id_from_path (orig_path) - req.input.read_string (req.content_length_value.as_integer_32) - l_put := req.input.last_string + l_put := retrieve_data (req) l_order := extract_order_request(l_put) if l_order /= Void and then db_access.orders.has_key (id) then l_order.set_id (id) @@ -234,8 +233,7 @@ feature -- HTTP Methods local l_post: STRING do - req.input.read_string (req.content_length_value.as_integer_32) - l_post := req.input.last_string + l_post := retrieve_data (req) if attached extract_order_request (l_post) as l_order then save_order (l_order) compute_response_post (ctx, req, res, l_order) @@ -358,6 +356,6 @@ feature {NONE} -- Implementation Repository Layer end note - copyright: "2011-2011, Javier Velilla and others" + copyright: "2011-2012, Javier Velilla and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/library/server/wsf/router/misc/request_resource_handler_helper.e b/library/server/wsf/router/misc/request_resource_handler_helper.e index 014059a2..ed1edee1 100644 --- a/library/server/wsf/router/misc/request_resource_handler_helper.e +++ b/library/server/wsf/router/misc/request_resource_handler_helper.e @@ -43,10 +43,14 @@ feature -- Method Post execute_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) do - if req.content_length_value > 0 then + if req.is_chunked_input then do_post (ctx, req, res) else - handle_bad_request_response ("Bad request, content_length empty", ctx, req, res) + if req.content_length_value > 0 then + do_post (ctx, req, res) + else + handle_bad_request_response ("Bad request, content_length empty", ctx, req, res) + end end end @@ -59,10 +63,14 @@ feature-- Method Put execute_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE) do - if req.content_length_value > 0 then + if req.is_chunked_input then do_put (ctx, req, res) else - handle_bad_request_response ("Bad request, content_length empty", ctx, req, res) + if req.content_length_value > 0 then + do_put (ctx, req, res) + else + handle_bad_request_response ("Bad request, content_length empty", ctx, req, res) + end end end @@ -155,6 +163,23 @@ feature -- Method Extension Method handle_not_implemented ("Method extension-method not implemented", ctx, req, res) end +feature -- Retrieve content from WGI_INPUT_STREAM + + retrieve_data ( req : WSF_REQUEST) : STRING + -- retrieve the content from the input stream + -- handle differents transfers + do + Result := "" + if req.is_chunked_input then + if attached req.chunked_input as l_chunked_input then + Result := l_chunked_input.data.as_string_8 + end + else + req.input.read_string (req.content_length_value.as_integer_32) + Result := req.input.last_string + end + end + feature -- Handle responses -- TODO Handle Content negotiation. -- The option : Server-driven negotiation: uses request headers to select a variant