From 7c95e514add84cdf080dac4db8a0756d2a13217f Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Mon, 30 Apr 2012 15:54:21 +0200 Subject: [PATCH] Added comments Added `url' to compute the url from base_url, path and query parameters --- .../http_client/src/http_client_session.e | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/library/client/http_client/src/http_client_session.e b/library/client/http_client/src/http_client_session.e index 24060d6f..af9cb3e7 100644 --- a/library/client/http_client/src/http_client_session.e +++ b/library/client/http_client/src/http_client_session.e @@ -50,35 +50,75 @@ feature {NONE} -- Initialization feature -- Basic operation + url (a_path: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT): STRING_8 + -- Url computed from Current and `ctx' data. + local + s: STRING_8 + url_encoder: URL_ENCODER + do + Result := base_url + a_path + if ctx /= Void then + create s.make_empty + create url_encoder + across + ctx.query_parameters as q + loop + if not s.is_empty then + s.append_character ('&') + end + s.append (url_encoder.encoded_string (q.key)) + s.append_character ('=') + s.append (url_encoder.encoded_string (q.item)) + end + if not s.is_empty then + Result.append_character ('?') + Result.append (s) + end + end + end + get (a_path: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT): HTTP_CLIENT_RESPONSE + -- Response for GET request based on Current, `a_path' and `ctx'. deferred end head (a_path: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT): HTTP_CLIENT_RESPONSE + -- Response for HEAD request based on Current, `a_path' and `ctx'. deferred end post (a_path: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; data: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE + -- Response for POST request based on Current, `a_path' and `ctx' + -- with input `data' deferred end post_file (a_path: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; fn: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE + -- Response for POST request based on Current, `a_path' and `ctx' + -- with uploaded data file `fn' 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' deferred end put_file (a_path: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; fn: detachable READABLE_STRING_8): HTTP_CLIENT_RESPONSE + -- Response for PUT request based on Current, `a_path' and `ctx' + -- with uploaded file `fn' deferred end delete (a_path: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT): HTTP_CLIENT_RESPONSE + -- Response for DELETE request based on Current, `a_path' and `ctx' deferred end @@ -114,8 +154,10 @@ feature -- Settings feature -- Access base_url: READABLE_STRING_8 + -- Base URL for any request created by Current session. headers: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8] + -- Headers common to any request created by Current session. feature -- Authentication