Removed HTTP_CLIENT_SESSION.post_multipart .. because it was not doing what the name might evoque

Restrict export of HTTP_CLIENT_REQUEST_CONTEXT.upload_data and upload_filename (and related) to .._SESSION and .._REQUEST
   this is mainly internal data, and is more about implementation than interface
This commit is contained in:
Jocelyn Fiat
2012-05-04 12:37:51 +02:00
parent 4508a76683
commit 3a979915f5
3 changed files with 46 additions and 44 deletions

View File

@@ -62,18 +62,20 @@ feature -- Access
form_parameters: HASH_TABLE [READABLE_STRING_32, READABLE_STRING_32]
-- Form parameters
proxy: detachable TUPLE [host: READABLE_STRING_8; port: INTEGER]
-- Optional proxy, see {HTTP_CLIENT_SESSION}.proxy
feature {HTTP_CLIENT_REQUEST, HTTP_CLIENT_SESSION} -- Internal access
upload_data: detachable READABLE_STRING_8
-- Upload data
--| Note: make sure to precise the Content-Type header
upload_filename: detachable READABLE_STRING_8
-- Upload data read from `upload_filename'
--| Note: make sure to precise the Content-Type header
--| Note: make sure to precise the Content-Type header
proxy: detachable TUPLE [host: READABLE_STRING_8; port: INTEGER]
-- Optional proxy, see {HTTP_CLIENT_SESSION}.proxy
feature -- Status report
feature {HTTP_CLIENT_REQUEST, HTTP_CLIENT_SESSION} -- Status report
has_form_data: BOOLEAN
do
@@ -112,6 +114,19 @@ feature -- Element change
credentials_required := b
end
feature -- Status setting
set_proxy (a_host: detachable READABLE_STRING_8; a_port: INTEGER)
do
if a_host = Void then
proxy := Void
else
proxy := [a_host, a_port]
end
end
feature {HTTP_CLIENT_REQUEST, HTTP_CLIENT_SESSION} -- Internal Element change
set_upload_data (a_data: like upload_data)
require
has_no_upload_data: not has_upload_data
@@ -126,15 +141,6 @@ feature -- Element change
upload_filename := a_fn
end
set_proxy (a_host: detachable READABLE_STRING_8; a_port: INTEGER)
do
if a_host = Void then
proxy := Void
else
proxy := [a_host, a_port]
end
end
feature -- Conversion helpers
query_parameters_to_url_encoded_string: STRING_8

View File

@@ -98,12 +98,6 @@ feature -- Basic operation
deferred
end
post_multipart (a_path: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; data: detachable READABLE_STRING_8; fn: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE
-- Response for POST request based on Current, `a_path' and `ctx'
-- with `data' and uploaded file `fn'
deferred
end
put (a_path: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; data: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE
-- Response for PUT request based on Current, `a_path' and `ctx'
-- with input `data'

View File

@@ -43,34 +43,12 @@ feature -- Basic operation
post (a_path: READABLE_STRING_8; a_ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; data: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE
do
Result := post_multipart (a_path, a_ctx, data, Void)
Result := impl_post (a_path, a_ctx, data, Void)
end
post_file (a_path: READABLE_STRING_8; a_ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; fn: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE
do
Result := post_multipart (a_path, a_ctx, Void, fn)
end
post_multipart (a_path: READABLE_STRING_8; a_ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; data: detachable READABLE_STRING_8; fn: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE
local
req: HTTP_CLIENT_REQUEST
ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT
do
ctx := a_ctx
if data /= Void then
if ctx = Void then
create ctx.make
end
ctx.set_upload_data (data)
end
if fn /= Void then
if ctx = Void then
create ctx.make
end
ctx.set_upload_filename (fn)
end
create {LIBCURL_HTTP_CLIENT_REQUEST} req.make (base_url + a_path, "POST", Current, ctx)
Result := req.execute
Result := impl_post (a_path, a_ctx, Void, fn)
end
put (a_path: READABLE_STRING_8; a_ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; data: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE
@@ -113,6 +91,30 @@ feature -- Basic operation
Result := req.execute
end
feature {NONE} -- Implementation
impl_post (a_path: READABLE_STRING_8; a_ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; data: detachable READABLE_STRING_8; fn: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE
local
req: HTTP_CLIENT_REQUEST
ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT
do
ctx := a_ctx
if data /= Void then
if ctx = Void then
create ctx.make
end
ctx.set_upload_data (data)
end
if fn /= Void then
if ctx = Void then
create ctx.make
end
ctx.set_upload_filename (fn)
end
create {LIBCURL_HTTP_CLIENT_REQUEST} req.make (base_url + a_path, "POST", Current, ctx)
Result := req.execute
end
feature {LIBCURL_HTTP_CLIENT_REQUEST} -- Curl implementation
curl: CURL_EXTERNALS