From 962154fc81bd8544a0ba355ad4b0223948207db0 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 1 Feb 2012 11:57:42 +0100 Subject: [PATCH] Eventually fixing trouble with c_strlen being over capacity (added this for testing, and while waiting a fix from EiffelcURL) --- .../spec/libcurl/libcurl_default_function.e | 94 +++++++++++++++++++ .../libcurl/libcurl_http_client_session.e | 1 + 2 files changed, 95 insertions(+) create mode 100644 library/client/http_client/src/spec/libcurl/libcurl_default_function.e diff --git a/library/client/http_client/src/spec/libcurl/libcurl_default_function.e b/library/client/http_client/src/spec/libcurl/libcurl_default_function.e new file mode 100644 index 00000000..036b5c1c --- /dev/null +++ b/library/client/http_client/src/spec/libcurl/libcurl_default_function.e @@ -0,0 +1,94 @@ +note + description: "[ + Default implementation of CURL_FUNCTION. + Fixing eventual issue from CURL_DEFAULT_FUNCTION + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date: 2009-04-09 20:51:20 +0200 (Thu, 09 Apr 2009) $" + revision: "$Revision: 78146 $" + +class + LIBCURL_DEFAULT_FUNCTION + +inherit + CURL_DEFAULT_FUNCTION + redefine + write_function, + debug_function, + dump + end + +create + make + +feature -- Command + + write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER + -- Redefine + local + l_c_string: C_STRING + l_identified: IDENTIFIED + do + Result := a_size * a_nmemb + create l_c_string.make_shared_from_pointer_and_count (a_data_pointer, Result) + + create l_identified + if attached {CURL_STRING} l_identified.id_object (a_object_id.to_integer_32) as l_string then + l_string.append (l_c_string.substring (1, Result)) + else + check False end + end + end + + debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER + -- Redefine + local + l_c_string: C_STRING + do + inspect + a_curl_infotype + when {CURL_INFO_TYPE}.curlinfo_data_in then + dump ("<= Recv data", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_data_out then + dump ("=> Send data", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_header_in then + dump ("<= Recv header", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_header_out then + dump ("=> Send header", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_ssl_data_in then + dump ("<= Recv SSL data", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_ssl_data_out then + dump ("=> Send SSL data", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_text then + create l_c_string.make_by_pointer_and_count (a_char_pointer, a_size) + print ("%N== Info: " + l_c_string.substring (1, a_size)) + else + check type_unknow: False end + end + end + +feature {NONE} -- Implementation + + dump (a_text: STRING; a_char_pointer: POINTER; a_size: INTEGER) + -- Dump debug information + local + l_c_string: C_STRING + do + create l_c_string.make_shared_from_pointer_and_count (a_char_pointer, a_size) + print ("%N" + a_text + "%N" + l_c_string.substring (1, a_size)) + end + +note + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/library/client/http_client/src/spec/libcurl/libcurl_http_client_session.e b/library/client/http_client/src/spec/libcurl/libcurl_http_client_session.e index 7853657b..d239573e 100644 --- a/library/client/http_client/src/spec/libcurl/libcurl_http_client_session.e +++ b/library/client/http_client/src/spec/libcurl/libcurl_http_client_session.e @@ -19,6 +19,7 @@ feature {NONE} -- Initialization do create curl -- cURL externals create curl_easy -- cURL easy externals + curl_easy.set_curl_function (create {LIBCURL_DEFAULT_FUNCTION}.make) end feature -- Basic operation