You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Patrick JUSSEAU <p....@ac-consulting.fr> on 2009/02/02 17:39:36 UTC
Newbie troubles....
Hi all,
I am pretty new to the http components world but I need to use it for
a simple case I need to deal with. What I need to do is :
1 - send a request using https to a remote server with a POST method
2- pass parameters to this request (key/value pairs)
3 - get a response back and read the response parameters
I tried to read through the examples but I can't find an easy way to
do this, I feel a little bit lost in the API. Could anyone point me to
the right direction?
Many thanks!!
Patrick
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: Newbie troubles....
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2009-02-02 at 20:47 +0100, Ortwin Glück wrote:
> Patrick,
>
> That's not really a standard for a response. So naturally we have no such
> parser. It's however easy to parse:
>
> 1. split by the & character using StringTokenizer
> 2. split each pair by the = character using String.indexOf
> 3. decode each name and value with URIDecoder
>
> Cheers,
>
> Ortwin
>
>
> Patrick JUSSEAU wrote:
> > Thanks Ortwin for the pointers, I see clearly now. I am able to send my
> > post request and get a response back from the https server. I was
> > however wondering if there is a utility class that parses the HttpEntity
> > response content in order to get key value pairs (the content of the
> > response entity is key1=value1&key2=value2&...) ?
> >
> > Something that would look like :
> >
> > HttpEntity resEntity = response.getEntity();
> > List<NameValuePair> nvps = SomeUtilityClass.getNameValuePairs();
> >
> > If such a class does not exist does it mean I need to parse it myself?
> >
Actually, there is a method like that in the
o.a.http.client.utils.URLEncodedUtils class.
Oleg
>
> > Thanks,
> >
> > Patrick
> >
> > On 2 févr. 09, at 18:16, Ortwin Glück wrote:
> >
> >> Patrick,
> >>
> >> Please see http://hc.apache.org/httpcomponents-client/examples.html
> >> There is examples for all your questions:
> >>
> >> 1. see Custom SSL context, see SSLSocketFactory
> >> 2. see Form based logon, see UrlEncodedFormEntity
> >> 3. Response handling, see HttpResponse, see ResponseHandler and
> >> HttpClient.execute(HttpUriRequest, ResponseHandler)
> >>
> >> Also visit the API Doc:
> >> http://hc.apache.org/httpcomponents-client/httpclient/apidocs/index.html
> >>
> >> Cheers,
> >>
> >> Ortwin
> >>
> >> Patrick JUSSEAU wrote:
> >>> Hi all,
> >>>
> >>> I am pretty new to the http components world but I need to use it for a
> >>> simple case I need to deal with. What I need to do is :
> >>>
> >>>
> >>> 1 - send a request using https to a remote server with a POST method
> >>> 2- pass parameters to this request (key/value pairs)
> >>> 3 - get a response back and read the response parameters
> >>>
> >>> I tried to read through the examples but I can't find an easy way to do
> >>> this, I feel a little bit lost in the API. Could anyone point me to the
> >>> right direction?
> >>>
> >>> Many thanks!!
> >>>
> >>>
> >>> Patrick
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> >>> For additional commands, e-mail: dev-help@hc.apache.org
> >>>
> >>
> >> --
> >> [web] http://www.odi.ch/
> >> [blog] http://www.odi.ch/weblog/
> >> [pgp] key 0x81CF3416
> >> finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> >> For additional commands, e-mail: dev-help@hc.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> > For additional commands, e-mail: dev-help@hc.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: Newbie troubles....
Posted by Patrick JUSSEAU <p....@ac-consulting.fr>.
Ok that's what I suspected I would have to do. Anyway thanks Ortwin
for your great support with httpcomponents !
Patrick
On 2 févr. 09, at 20:47, Ortwin Glück wrote:
> Patrick,
>
> That's not really a standard for a response. So naturally we have no
> such
> parser. It's however easy to parse:
>
> 1. split by the & character using StringTokenizer
> 2. split each pair by the = character using String.indexOf
> 3. decode each name and value with URIDecoder
>
> Cheers,
>
> Ortwin
>
> Patrick JUSSEAU wrote:
>> Thanks Ortwin for the pointers, I see clearly now. I am able to
>> send my
>> post request and get a response back from the https server. I was
>> however wondering if there is a utility class that parses the
>> HttpEntity
>> response content in order to get key value pairs (the content of the
>> response entity is key1=value1&key2=value2&...) ?
>>
>> Something that would look like :
>>
>> HttpEntity resEntity = response.getEntity();
>> List<NameValuePair> nvps = SomeUtilityClass.getNameValuePairs();
>>
>> If such a class does not exist does it mean I need to parse it
>> myself?
>>
>> Thanks,
>>
>> Patrick
>>
>> On 2 févr. 09, at 18:16, Ortwin Glück wrote:
>>
>>> Patrick,
>>>
>>> Please see http://hc.apache.org/httpcomponents-client/examples.html
>>> There is examples for all your questions:
>>>
>>> 1. see Custom SSL context, see SSLSocketFactory
>>> 2. see Form based logon, see UrlEncodedFormEntity
>>> 3. Response handling, see HttpResponse, see ResponseHandler and
>>> HttpClient.execute(HttpUriRequest, ResponseHandler)
>>>
>>> Also visit the API Doc:
>>> http://hc.apache.org/httpcomponents-client/httpclient/apidocs/index.html
>>>
>>> Cheers,
>>>
>>> Ortwin
>>>
>>> Patrick JUSSEAU wrote:
>>>> Hi all,
>>>>
>>>> I am pretty new to the http components world but I need to use it
>>>> for a
>>>> simple case I need to deal with. What I need to do is :
>>>>
>>>>
>>>> 1 - send a request using https to a remote server with a POST
>>>> method
>>>> 2- pass parameters to this request (key/value pairs)
>>>> 3 - get a response back and read the response parameters
>>>>
>>>> I tried to read through the examples but I can't find an easy way
>>>> to do
>>>> this, I feel a little bit lost in the API. Could anyone point me
>>>> to the
>>>> right direction?
>>>>
>>>> Many thanks!!
>>>>
>>>>
>>>> Patrick
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>>>> For additional commands, e-mail: dev-help@hc.apache.org
>>>>
>>>
>>> --
>>> [web] http://www.odi.ch/
>>> [blog] http://www.odi.ch/weblog/
>>> [pgp] key 0x81CF3416
>>> finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: dev-help@hc.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>> For additional commands, e-mail: dev-help@hc.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: Newbie troubles....
Posted by Ortwin Glück <od...@odi.ch>.
Patrick,
That's not really a standard for a response. So naturally we have no such
parser. It's however easy to parse:
1. split by the & character using StringTokenizer
2. split each pair by the = character using String.indexOf
3. decode each name and value with URIDecoder
Cheers,
Ortwin
Patrick JUSSEAU wrote:
> Thanks Ortwin for the pointers, I see clearly now. I am able to send my
> post request and get a response back from the https server. I was
> however wondering if there is a utility class that parses the HttpEntity
> response content in order to get key value pairs (the content of the
> response entity is key1=value1&key2=value2&...) ?
>
> Something that would look like :
>
> HttpEntity resEntity = response.getEntity();
> List<NameValuePair> nvps = SomeUtilityClass.getNameValuePairs();
>
> If such a class does not exist does it mean I need to parse it myself?
>
> Thanks,
>
> Patrick
>
> On 2 févr. 09, at 18:16, Ortwin Glück wrote:
>
>> Patrick,
>>
>> Please see http://hc.apache.org/httpcomponents-client/examples.html
>> There is examples for all your questions:
>>
>> 1. see Custom SSL context, see SSLSocketFactory
>> 2. see Form based logon, see UrlEncodedFormEntity
>> 3. Response handling, see HttpResponse, see ResponseHandler and
>> HttpClient.execute(HttpUriRequest, ResponseHandler)
>>
>> Also visit the API Doc:
>> http://hc.apache.org/httpcomponents-client/httpclient/apidocs/index.html
>>
>> Cheers,
>>
>> Ortwin
>>
>> Patrick JUSSEAU wrote:
>>> Hi all,
>>>
>>> I am pretty new to the http components world but I need to use it for a
>>> simple case I need to deal with. What I need to do is :
>>>
>>>
>>> 1 - send a request using https to a remote server with a POST method
>>> 2- pass parameters to this request (key/value pairs)
>>> 3 - get a response back and read the response parameters
>>>
>>> I tried to read through the examples but I can't find an easy way to do
>>> this, I feel a little bit lost in the API. Could anyone point me to the
>>> right direction?
>>>
>>> Many thanks!!
>>>
>>>
>>> Patrick
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: dev-help@hc.apache.org
>>>
>>
>> --
>> [web] http://www.odi.ch/
>> [blog] http://www.odi.ch/weblog/
>> [pgp] key 0x81CF3416
>> finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>> For additional commands, e-mail: dev-help@hc.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: Newbie troubles....
Posted by Patrick JUSSEAU <p....@ac-consulting.fr>.
Thanks Ortwin for the pointers, I see clearly now. I am able to send
my post request and get a response back from the https server. I was
however wondering if there is a utility class that parses the
HttpEntity response content in order to get key value pairs (the
content of the response entity is key1=value1&key2=value2&...) ?
Something that would look like :
HttpEntity resEntity = response.getEntity();
List<NameValuePair> nvps = SomeUtilityClass.getNameValuePairs();
If such a class does not exist does it mean I need to parse it myself?
Thanks,
Patrick
On 2 févr. 09, at 18:16, Ortwin Glück wrote:
> Patrick,
>
> Please see http://hc.apache.org/httpcomponents-client/examples.html
> There is examples for all your questions:
>
> 1. see Custom SSL context, see SSLSocketFactory
> 2. see Form based logon, see UrlEncodedFormEntity
> 3. Response handling, see HttpResponse, see ResponseHandler and
> HttpClient.execute(HttpUriRequest, ResponseHandler)
>
> Also visit the API Doc:
> http://hc.apache.org/httpcomponents-client/httpclient/apidocs/index.html
>
> Cheers,
>
> Ortwin
>
> Patrick JUSSEAU wrote:
>> Hi all,
>>
>> I am pretty new to the http components world but I need to use it
>> for a
>> simple case I need to deal with. What I need to do is :
>>
>>
>> 1 - send a request using https to a remote server with a POST method
>> 2- pass parameters to this request (key/value pairs)
>> 3 - get a response back and read the response parameters
>>
>> I tried to read through the examples but I can't find an easy way
>> to do
>> this, I feel a little bit lost in the API. Could anyone point me to
>> the
>> right direction?
>>
>> Many thanks!!
>>
>>
>> Patrick
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>> For additional commands, e-mail: dev-help@hc.apache.org
>>
>
> --
> [web] http://www.odi.ch/
> [blog] http://www.odi.ch/weblog/
> [pgp] key 0x81CF3416
> finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: Newbie troubles....
Posted by Ortwin Glück <od...@odi.ch>.
Patrick,
Please see http://hc.apache.org/httpcomponents-client/examples.html
There is examples for all your questions:
1. see Custom SSL context, see SSLSocketFactory
2. see Form based logon, see UrlEncodedFormEntity
3. Response handling, see HttpResponse, see ResponseHandler and
HttpClient.execute(HttpUriRequest, ResponseHandler)
Also visit the API Doc:
http://hc.apache.org/httpcomponents-client/httpclient/apidocs/index.html
Cheers,
Ortwin
Patrick JUSSEAU wrote:
> Hi all,
>
> I am pretty new to the http components world but I need to use it for a
> simple case I need to deal with. What I need to do is :
>
>
> 1 - send a request using https to a remote server with a POST method
> 2- pass parameters to this request (key/value pairs)
> 3 - get a response back and read the response parameters
>
> I tried to read through the examples but I can't find an easy way to do
> this, I feel a little bit lost in the API. Could anyone point me to the
> right direction?
>
> Many thanks!!
>
>
> Patrick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
--
[web] http://www.odi.ch/
[blog] http://www.odi.ch/weblog/
[pgp] key 0x81CF3416
finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org