diff --git a/library/server/wsf/src/response/wsf_not_found_response.e b/library/server/wsf/src/response/wsf_not_found_response.e new file mode 100644 index 00000000..3a17cf0f --- /dev/null +++ b/library/server/wsf/src/response/wsf_not_found_response.e @@ -0,0 +1,128 @@ +note + description: "[ + This class is used to report a 404 Not found page + ]" + date: "$Date$" + revision: "$Revision$" + +class + WSF_NOT_FOUND_RESPONSE + + +inherit + WSF_RESPONSE_MESSAGE + + SHARED_HTML_ENCODER + +create + make + +feature {NONE} -- Initialization + + make (req: WSF_REQUEST) + do + request := req + create header.make + create suggested_locations.make (0) + end + +feature -- Header + + header: HTTP_HEADER + -- Response' header + + request: WSF_REQUEST + -- Associated request. + + suggested_locations: ARRAYED_LIST [TUPLE [location: READABLE_STRING_8; title: detachable READABLE_STRING_GENERAL]] + -- Optional suggestions + -- First is the default. + +feature -- Element change + + add_suggested_location (a_loc: READABLE_STRING_8; a_title: detachable READABLE_STRING_GENERAL) + -- Add `a_loc' to `suggested_locations' + do + suggested_locations.force ([a_loc, a_title]) + end + +feature {WSF_RESPONSE} -- Output + + send_to (res: WSF_RESPONSE) + local + s: STRING + l_title: detachable READABLE_STRING_GENERAL + h: like header + do + h := header + res.set_status_code ({HTTP_STATUS_CODE}.not_found) + + s := "" + s.append ("") + s.append (html_encoder.encoded_string (request.request_uri)) + s.append (" - 404 Not Found") + s.append ("%N") + s.append ("[ + + + + + ]") + s.append ("
") + s.append ("
") + s.append ("
") + s.append ("
") + s.append ("
") + s.append ("404 Not Found
") + s.append ("
404 Not Found: " + html_encoder.encoded_string (request.request_uri) + "
") + if attached suggested_locations as lst and then not lst.is_empty then + s.append ("
Perhaps your are looking for:
%N") + end + s.append ("
") + s.append ("%N") + s.append ("%N") + + h.put_content_length (s.count) + h.put_content_type_text_html + res.put_header_text (h.string) + res.put_string (s) + res.flush + end + +note + copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end