From 18ced46c9900807a4e27d2b2e45fe630b42dfa6d Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 2 May 2012 11:35:53 +0200 Subject: [PATCH] Removed implicit conversion from HTTP_CONTENT_TYPE to STRING_8 because it could be a source of bug due to hidden conversion (and parameters) Applied changes to autotest cases Cosmetic --- library/protocol/http/src/http_content_type.e | 3 +- library/protocol/http/src/http_media_type.e | 5 +-- .../wsf/src/support/wsf_mime_handler_helper.e | 1 - library/server/wsf/src/wsf_request.e | 4 +- .../server/wsf/tests/echo/src/echo_server.e | 1 + .../server/wsf/tests/src/test_wsf_request.e | 41 ++++++++++++++++++- .../src/test_wsf_request_chunked_input.e | 1 - 7 files changed, 46 insertions(+), 10 deletions(-) diff --git a/library/protocol/http/src/http_content_type.e b/library/protocol/http/src/http_content_type.e index 718e8162..552ff4db 100644 --- a/library/protocol/http/src/http_content_type.e +++ b/library/protocol/http/src/http_content_type.e @@ -16,8 +16,7 @@ create make_from_string convert - make_from_string ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8}), - string: {READABLE_STRING_8} + make_from_string ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8}) feature -- Access diff --git a/library/protocol/http/src/http_media_type.e b/library/protocol/http/src/http_media_type.e index 7674bb2b..0465f1be 100644 --- a/library/protocol/http/src/http_media_type.e +++ b/library/protocol/http/src/http_media_type.e @@ -41,8 +41,7 @@ create make_from_string convert - make_from_string ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8}), - string: {READABLE_STRING_8} + make_from_string ({READABLE_STRING_8, STRING_8, IMMUTABLE_STRING_8}) feature {NONE} -- Initialization @@ -227,7 +226,7 @@ feature -- Status report end same_simple_type (s: READABLE_STRING_8): BOOLEAN - -- Current has same type/subtype string representation as `s'? + -- Current has same type/subtype string representation as `s'? do Result := simple_type.same_string (s) end diff --git a/library/server/wsf/src/support/wsf_mime_handler_helper.e b/library/server/wsf/src/support/wsf_mime_handler_helper.e index 8802b6dc..fff2cbcf 100644 --- a/library/server/wsf/src/support/wsf_mime_handler_helper.e +++ b/library/server/wsf/src/support/wsf_mime_handler_helper.e @@ -87,7 +87,6 @@ feature {NONE} -- Implementation if p > 0 then q := r.index_of ({CHARACTER_32} ']', p + 1) if q > p then --- k32 := url_encoder.decoded_string (k) if attached {WSF_TABLE} ptb.value (k) as l_tb_value then tb := l_tb_value else diff --git a/library/server/wsf/src/wsf_request.e b/library/server/wsf/src/wsf_request.e index 15f8bbeb..599a01a2 100644 --- a/library/server/wsf/src/wsf_request.e +++ b/library/server/wsf/src/wsf_request.e @@ -80,7 +80,7 @@ feature {NONE} -- Initialization -- Content-Type s8 := wgi_request.content_type if s8 /= Void then - content_type := s8 + create content_type.make_from_string (s8) else content_type := Void end @@ -1111,7 +1111,7 @@ feature -- Form fields and related feature -- Access: MIME handler - has_mime_handler (a_content_type: READABLE_STRING_8): BOOLEAN + has_mime_handler (a_content_type: HTTP_CONTENT_TYPE): BOOLEAN -- Has a MIME handler registered for `a_content_type'? do if attached mime_handlers as hdls then diff --git a/library/server/wsf/tests/echo/src/echo_server.e b/library/server/wsf/tests/echo/src/echo_server.e index 27537277..0ff1a36b 100644 --- a/library/server/wsf/tests/echo/src/echo_server.e +++ b/library/server/wsf/tests/echo/src/echo_server.e @@ -19,6 +19,7 @@ feature {NONE} -- Initialization -- Initialize `Current'. do set_service_option ("port", 9091) + set_service_option ("verbose", True) make_and_launch end diff --git a/library/server/wsf/tests/src/test_wsf_request.e b/library/server/wsf/tests/src/test_wsf_request.e index 9c421883..9017133d 100644 --- a/library/server/wsf/tests/src/test_wsf_request.e +++ b/library/server/wsf/tests/src/test_wsf_request.e @@ -36,6 +36,7 @@ feature {NONE} -- Events wt: WORKER_THREAD e: EXECUTION_ENVIRONMENT do +-- port_number := 9091 port_number := 0 base_url := "test/" create app.make_custom (to_wgi_service, base_url) @@ -50,11 +51,41 @@ feature {NONE} -- Events port_number := app.port end + server_log_name: STRING + local + fn: FILE_NAME + once + create fn.make_from_string ("..") + fn.extend ("..") + fn.extend ("..") + fn.extend ("..") + fn.extend ("..") + fn.extend ("server_test.log") + Result := fn.string + end + + server_log (m: STRING_8) + local + f: RAW_FILE + do + create f.make_open_append (server_log_name)--"..\server-tests.log") + f.put_string (m) + f.put_character ('%N') + f.close + end + execute (req: WSF_REQUEST; res: WSF_RESPONSE) local q: detachable STRING_32 page: WSF_PAGE_RESPONSE do + debug + server_log (req.request_uri) + if attached req.content_type as l_content_type then + server_log ("content_type:" + l_content_type.string) + end + end + create page.make if attached req.request_uri as l_uri then if l_uri.starts_with (test_url ("get/01")) then @@ -93,17 +124,24 @@ feature {NONE} -- Events end create q.make_empty - +-- req.set_raw_input_data_recorded (True) across req.form_parameters as fcur loop + debug + server_log ("%Tform: " + fcur.item.name) + end if not q.is_empty then q.append_character ('&') end q.append (fcur.item.name.as_string_32 + "=" + fcur.item.as_string) end +-- if attached req.raw_input_data as d then +-- server_log ("Raw data=" + d) +-- end + if not q.is_empty then page.put_string (" : " + q ) end @@ -154,6 +192,7 @@ feature {NONE} -- Events http_session := sess sess.set_timeout (-1) sess.set_connect_timeout (-1) +-- sess.set_proxy ("127.0.0.1", 8888) --| inspect traffic with http://www.fiddler2.com/ end end diff --git a/library/server/wsf/tests/src/test_wsf_request_chunked_input.e b/library/server/wsf/tests/src/test_wsf_request_chunked_input.e index 24a2bc5a..5ee75346 100644 --- a/library/server/wsf/tests/src/test_wsf_request_chunked_input.e +++ b/library/server/wsf/tests/src/test_wsf_request_chunked_input.e @@ -24,7 +24,6 @@ feature {NONE} -- Helpers do Result := Precursor (ctx) Result.headers.extend ("chunked", "Transfer-Encoding") --- Result.set_proxy ("127.0.0.1", 8888) --| inspect traffic with http://www.fiddler2.com/ end feature -- Test routines