Added http header related features. It means we can change http header by setting a list ourself.

Wrapped more cURL constants.

Added `release_item' in {CURL_FORM} which is useful to clean the {CURL_FORM} generated by {CURL_EXTERNALS}.formadd_string_string.

git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71685 8089f293-4706-0410-a29e-feb5c42a2edf
This commit is contained in:
larryl
2007-12-31 09:48:53 +00:00
parent 5980a724cc
commit 987c18198e
5 changed files with 63 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ feature -- Command
-- Redefine
local
l_c_string: C_STRING
l_string: STRING
l_string: CURL_STRING
l_identified: IDENTIFIED
do
Result := a_size * a_nmemb
@@ -85,9 +85,8 @@ feature {NONE} -- Implementation
local
l_c_string: C_STRING
do
print ("%N" + a_text)
create l_c_string.share_from_pointer_and_count (a_char_pointer, a_size)
print ("%N" + l_c_string.string)
print ("%N" + a_text + "%N" + l_c_string.string)
end
indexing

View File

@@ -54,6 +54,16 @@ feature -- Command
setopt_void_star (a_curl_handle, a_opt, a_form.item)
end
setopt_slist (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_slist: POINTER) is
-- Declared as curl_easy_setopt().
require
exists: a_curl_handle /= default_pointer
valid: a_opt = {CURL_OPT_CONSTANTS}.curlopt_httpheader
exists: a_curl_slist /= default_pointer
do
setopt_void_star (a_curl_handle, a_opt, a_curl_slist)
end
setopt_curl_string (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_string: CURL_STRING) is
-- Declared as curl_easy_setopt().
require

View File

@@ -52,6 +52,22 @@ feature -- Command
end
end
slist_append (a_list: POINTER; a_string: STRING_GENERAL): POINTER is
-- Declared as curl_slist_append ().
require
exists: a_list /= default_pointer
not_void: a_string /= Void
local
l_c_string: C_STRING
l_api: POINTER
do
l_api := api_loader.safe_load_api (module_name, "curl_slist_append")
if l_api /= default_pointer then
create l_c_string.make (a_string)
Result := c_slist_append (l_api, a_list, l_c_string.item)
end
end
feature -- Query
is_dynamic_library_exists: BOOLEAN is
@@ -64,6 +80,9 @@ feature {CURL_FORM} -- Internal command
formfree (a_curl_form: POINTER) is
-- Declared as curl_formfree ().
-- See: http://curl.askapache.com/libcurl/c/curl_formfree.html
-- curl_formfree() is used to clean up data previously built/appended with curl_formadd(3).
-- This must be called when the data has been used, which typically means after the curl_easy_perform(3) has been called.
require
exists: a_curl_form /= default_pointer
local

View File

@@ -62,6 +62,13 @@ feature -- Command
end
end
release_item is
-- Release item
-- NOT free memory! This is useful if Current generated by {CURL_EXTERNALS}.formadd_string_string.
do
item := default_pointer
end
feature {CURL_EXTERNALS} -- Internal command
set_item (a_item: POINTER) is

View File

@@ -184,6 +184,28 @@ feature -- Enumerations.
]"
end
curlopt_referer: INTEGER is
-- Declared as CURLOPT_REFERER
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_REFERER;
]"
end
curlopt_httpget: INTEGER is
-- Declared as CURLOPT_HTTPGET
-- Pass a long. If the long is non-zero, this forces the HTTP request to get back to GET. usable if a POST, HEAD, PUT or a custom request have been used previously using the same curl handle.
-- When setting CURLOPT_HTTPGET to a non-zero value, it will automatically set CURLOPT_NOBODY to 0 (since 7.14.1).
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_HTTPGET;
]"
end
is_valid (a_integer: INTEGER): BOOLEAN is
-- If `a_integer' value vaild?
do
@@ -203,7 +225,9 @@ feature -- Enumerations.
a_integer = curlopt_writefunction or
a_integer = curlopt_progressfunction or
a_integer = curlopt_progressdata or
a_integer = curlopt_noprogress
a_integer = curlopt_noprogress or
a_integer = curlopt_referer or
a_integer = curlopt_httpget
end
indexing