test EWF ... put current folder under "post" directory , located directly in the EWF git working copy.
Last active
November 4, 2015 23:24
-
-
Save jocelyn/bdc38a1754758e887f93 to your computer and use it in GitHub Desktop.
ewf_encoding_test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| note | |
| description: "Basic Service launcher" | |
| class | |
| APPLICATION | |
| inherit | |
| WSF_DEFAULT_SERVICE [APPLICATION_EXECUTION] | |
| redefine | |
| initialize | |
| end | |
| create | |
| make_and_launch | |
| feature {NONE} -- Initialization | |
| initialize | |
| -- Initialize current service. | |
| local | |
| s32: STRING_32 | |
| s8: STRING_8 | |
| -- encs: SYSTEM_ENCODINGS | |
| do | |
| set_service_option ("port", 9090) | |
| create s32.make_empty | |
| s32.append_code (40) | |
| s32.append_code (151) | |
| s32.append_code (8212) | |
| s32 := {STRING_32} "—" | |
| create s8.make_empty | |
| s8.append_code (40) | |
| s8.append_code (151) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| note | |
| description : "Reading Parameters from a HTML FORM (method POST) " | |
| date : "$Date$" | |
| revision : "$Revision$" | |
| class | |
| APPLICATION_EXECUTION | |
| inherit | |
| WSF_EXECUTION | |
| SHARED_HTML_ENCODER | |
| create | |
| make | |
| feature -- Basic operations | |
| page_html_test: STRING | |
| local | |
| uc: STRING_32 | |
| utf: UTF_CONVERTER | |
| do | |
| Result := "[ | |
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>EWF Handling Client Request: Form example </title> | |
| </head> | |
| <body> | |
| <h1> EWF encoding test.</h1> | |
| <form action="$ACTION" method="$METHOD"> | |
| <input name="form_op" type="hidden" value="submit"/> | |
| <input name="form_method" type="hidden" value="$METHOD"/> | |
| <div> | |
| <label>First Name | |
| <input name="given-name" type="text" required value="你"/> | |
| </label> | |
| </div> | |
| <div> | |
| <label>lst | |
| <input name="lst[]" type="text" value="a"/> | |
| <input name="lst[]" type="text" value="b"/> | |
| <input name="lst[]" type="text" value="c"/> | |
| </label> | |
| </div> | |
| <div> | |
| <label>tb | |
| <input name="tb[a]" type="text" value="foo"/> | |
| <input name="tb[b]" type="text" value="bar"/> | |
| </label> | |
| </div> | |
| <div> | |
| <label>unicode field names... | |
| <input name="été_name" type="text" value="été"/> | |
| <input name="$UTF8NAME_iso_name" type="text" value="$UTF8NAME"/> | |
| <br/> | |
| <input name="$UTF8NAME_list[$UTF8NAME]_iso_name" type="text" value="iso-summer 你"/> | |
| <input name="$UTF8NAME_list[été_name]" type="text" value="summer 你"/> | |
| <br/> | |
| <input name="$UTF8NAME_tb[a]" type="text" value="foo"/> | |
| <input name="$UTF8NAME_tb[b]" type="text" value="bar"/> | |
| <input name="foo[$UTF8NAME_1][bar][a]" type="text" value="abc"/> | |
| <input name="foo[$UTF8NAME_1][bar][b]" type="text" value="123"/> | |
| <input name="foo[$UTF8NAME_2][bar][a]" type="text" value="abc"/> | |
| <input name="foo[$UTF8NAME_2][bar][b]" type="text" value="123"/> | |
| </label> | |
| </div> | |
| <button type="submit">Submit Form</button> | |
| </form> | |
| </body> | |
| </html> | |
| ]" | |
| Result.replace_substring_all ("$ACTION", request.request_uri) | |
| create uc.make_empty | |
| uc.append_code (20320) | |
| Result.replace_substring_all ("$UTF8NAME", utf.utf_32_string_to_utf_8_string_8 (uc)) | |
| if attached {WSF_STRING} request.query_parameter ("method") as l_method then | |
| Result.replace_substring_all ("$METHOD", l_method.url_encoded_value.as_upper) | |
| else | |
| Result.replace_substring_all ("$METHOD", "POST") | |
| end | |
| end | |
| page_html_test2: STRING | |
| do | |
| Result := page_html_test | |
| Result.replace_substring_all ("method=%"POST%"", "method=%"POST%" enctype=%"multipart/form-data%"") | |
| end | |
| page_html_test3: STRING | |
| do | |
| Result := page_html_test | |
| Result.replace_substring_all ("method=%"POST%"", "method=%"POST%" enctype=%"multipart/form-data; charset=utf-8%"") | |
| end | |
| execute | |
| -- Execute the incomming request | |
| do | |
| request.set_raw_input_data_recorded (True) | |
| if attached request.string_item ("form_op") as l_op and then l_op.is_case_insensitive_equal_general ("submit") then | |
| process_form | |
| else | |
| send_form | |
| end | |
| -- if request.is_get_request_method then | |
| -- do_get | |
| -- elseif request.is_post_request_method then | |
| -- do_post | |
| -- else | |
| -- -- Here we should handle unexpected errors. | |
| -- response.send (create {WSF_NOT_IMPLEMENTED_RESPONSE}.make (request)) | |
| -- end | |
| end | |
| send_form | |
| local | |
| msg: WSF_PAGE_RESPONSE | |
| test: INTEGER | |
| do | |
| test := 1 | |
| if attached request.string_item ("test") as s and then s.is_integer then | |
| test := s.to_integer | |
| else | |
| test := 1 | |
| end | |
| inspect test | |
| when 2 then | |
| create msg.make_with_body (page_html_test2) | |
| when 3 then | |
| create msg.make_with_body (page_html_test3) | |
| else | |
| -- #1 | |
| create msg.make_with_body (page_html_test) | |
| end | |
| msg.header.add_content_type_with_charset ("text/html", "utf-8") | |
| response.send (msg) | |
| end | |
| process_form | |
| local | |
| msg: STRING | |
| l_parameter_names: STRING | |
| l_answer: STRING | |
| idioms: LIST [STRING_32] | |
| l_raw_data: STRING | |
| dbg: WSF_DEBUG_INFORMATION | |
| l_parameters: ITERABLE [WSF_VALUE] | |
| do | |
| -- (3) Read Raw Data | |
| create l_raw_data.make_empty | |
| request.read_input_data_into (l_raw_data) | |
| -- (2) Multiple values | |
| if attached request.string_item ("form_method") as l_method and then l_method.is_case_insensitive_equal_general ("get") then | |
| l_parameters := request.query_parameters | |
| if attached {WSF_MULTIPLE_STRING} request.query_parameter ("languages") as l_languages then | |
| -- Get all the associated values | |
| create {ARRAYED_LIST [STRING_32]} idioms.make (2) | |
| across l_languages as ic loop idioms.force (ic.item.value) end | |
| elseif attached {WSF_STRING} request.query_parameter ("languages") as l_language then | |
| -- Single value | |
| print (l_language.value) | |
| else | |
| -- Value Missing | |
| end | |
| else | |
| l_parameters := request.form_parameters | |
| if attached {WSF_MULTIPLE_STRING} request.form_parameter ("languages") as l_languages then | |
| -- Get all the associated values | |
| create {ARRAYED_LIST [STRING_32]} idioms.make (2) | |
| across l_languages as ic loop idioms.force (ic.item.value) end | |
| elseif attached {WSF_STRING} request.form_parameter ("languages") as l_language then | |
| -- Single value | |
| print (l_language.value) | |
| else | |
| -- Value Missing | |
| end | |
| end | |
| -- Read the all parameters names and his values. | |
| create l_parameter_names.make_from_string ("<h2>Parameters Names</h2>") | |
| l_parameter_names.append ("<br>%N") | |
| create l_answer.make_from_string ("<h2>Parameter Names and Values</h2>") | |
| l_answer.append ("<br>%N") | |
| across | |
| l_parameters as ic | |
| loop | |
| l_parameter_names.append (html_encoder.general_encoded_string (ic.item.key)) | |
| l_parameter_names.append ("<br>%N") | |
| l_answer.append (html_encoder.general_encoded_string (ic.item.key)) | |
| l_answer.append_character ('=') | |
| if attached {WSF_STRING} ic.item as l_value then | |
| l_answer.append_string (html_encoder.general_encoded_string (l_value.value)) | |
| elseif attached {WSF_TABLE} ic.item as l_table then | |
| l_answer.append_string ("<table><tr>") | |
| across | |
| l_table as tb_ic | |
| loop | |
| l_answer.append_string (html_encoder.general_encoded_string (tb_ic.item.string_representation)) | |
| end | |
| l_answer.append_string ("</tr></table>%N") | |
| end | |
| l_answer.append ("<br>%N") | |
| end | |
| create msg.make_empty | |
| msg.append (l_parameter_names) | |
| msg.append ("<br>%N") | |
| msg.append_string (l_answer) | |
| msg.append ("<br>%N") | |
| msg.append ("<h2>Raw content</h2>") | |
| msg.append (l_raw_data) | |
| create dbg.make | |
| dbg.set_unicode_output_enabled (True) | |
| msg.append ("<pre>") | |
| dbg.append_query_parameters_to (request, response, msg) | |
| dbg.append_form_parameters_to (request, response, msg) | |
| msg.append ("</pre>") | |
| response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html; charset=%"utf-8%""], ["Content-Length", msg.count.out]>>) | |
| response.put_string (msg) | |
| end | |
| check_value (s: READABLE_STRING_32) | |
| local | |
| sys: SYSTEM_ENCODINGS | |
| v: READABLE_STRING_GENERAL | |
| e1,e2,eutf32: ENCODING | |
| f,t: ENCODING | |
| do | |
| create sys | |
| e1 := sys.iso_8859_1 | |
| e2 := sys.system_encoding | |
| eutf32 := sys.utf32 | |
| f := e2 | |
| t := e1 | |
| f.convert_to (t, s) | |
| v := f.last_converted_string_32 | |
| f := e1 | |
| t := e2 | |
| f.convert_to (t, s) | |
| v := f.last_converted_string_32 | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="ISO-8859-1"?> | |
| <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="es_form" uuid="C28C4F53-9963-46C0-A080-8F13E94E7486" library_target="es_form"> | |
| <target name="common" abstract="true"> | |
| <file_rule> | |
| <exclude>/EIFGENs$</exclude> | |
| <exclude>/CVS$</exclude> | |
| <exclude>/.svn$</exclude> | |
| </file_rule> | |
| <option warning="true" full_class_checking="false" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> | |
| <library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/> | |
| <library name="encoding" location="$ISE_LIBRARY\library\encoding\encoding-safe.ecf"/> | |
| <library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/> | |
| <library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf" readonly="false"/> | |
| <library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf"/> | |
| </target> | |
| <target name="es_form_standalone" extends="common"> | |
| <root class="APPLICATION" feature="make_and_launch"/> | |
| <option warning="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="default_standalone" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\standalone-safe.ecf"/> | |
| <cluster name="es_form" location=".\" recursive="true"/> | |
| </target> | |
| <target name="es_form_nino" extends="common"> | |
| <root class="APPLICATION" feature="make_and_launch"/> | |
| <option warning="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/> | |
| <cluster name="es_form" location=".\" recursive="true"/> | |
| </target> | |
| <target name="es_form_cgi" extends="common"> | |
| <root class="APPLICATION" feature="make_and_launch"/> | |
| <option warning="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/> | |
| <cluster name="es_form" location=".\" recursive="true"/> | |
| </target> | |
| <target name="es_form_libfcgi" extends="common"> | |
| <root class="APPLICATION" feature="make_and_launch"/> | |
| <option warning="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/> | |
| <cluster name="es_form" location=".\" recursive="true"/> | |
| </target> | |
| <target name="es_form" extends="es_form_standalone"> | |
| </target> | |
| </system> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="ISO-8859-1"?> | |
| <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="form" uuid="C28C4F53-9963-46C0-A080-8F13E94E7486" library_target="form"> | |
| <target name="common" abstract="true"> | |
| <file_rule> | |
| <exclude>/EIFGENs$</exclude> | |
| <exclude>/CVS$</exclude> | |
| <exclude>/.svn$</exclude> | |
| </file_rule> | |
| <option warning="true" full_class_checking="false" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> | |
| <library name="encoder" location="..\..\library\text\encoder\encoder-safe.ecf"/> | |
| <library name="encoding" location="$ISE_LIBRARY\library\encoding\encoding-safe.ecf"/> | |
| <library name="http" location="..\..\library\network\protocol\http\http-safe.ecf"/> | |
| <library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf" readonly="false"/> | |
| <library name="wsf_extension" location="..\..\library\server\wsf\wsf_extension-safe.ecf" readonly="false"/> | |
| </target> | |
| <target name="form_standalone" extends="common"> | |
| <root class="APPLICATION" feature="make_and_launch"/> | |
| <option warning="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="default_standalone" location="..\..\library\server\wsf\default\standalone-safe.ecf"/> | |
| <cluster name="form" location=".\" recursive="true"/> | |
| </target> | |
| <target name="form_nino" extends="common"> | |
| <root class="APPLICATION" feature="make_and_launch"/> | |
| <option warning="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf"/> | |
| <cluster name="form" location=".\" recursive="true"/> | |
| </target> | |
| <target name="form_cgi" extends="common"> | |
| <root class="APPLICATION" feature="make_and_launch"/> | |
| <option warning="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="default_cgi" location="..\..\library\server\wsf\default\cgi-safe.ecf"/> | |
| <cluster name="form" location=".\" recursive="true"/> | |
| </target> | |
| <target name="form_libfcgi" extends="common"> | |
| <root class="APPLICATION" feature="make_and_launch"/> | |
| <option warning="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="transitional" syntax="transitional"> | |
| <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> | |
| </option> | |
| <library name="default_libfcgi" location="..\..\library\server\wsf\default\libfcgi-safe.ecf"/> | |
| <cluster name="form" location=".\" recursive="true"/> | |
| </target> | |
| <target name="form" extends="form_standalone"> | |
| </target> | |
| </system> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment