[COTDC] 3 - HTTPClient

classic Classic list List threaded Threaded
23 messages Options
12
laurent laffont laurent laffont
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[COTDC] 3 - HTTPClient

Comment Of The Day Contest - One Day One Comment
Rules: Each day a not commented class is elected. Each day the best comment will be integrated with name of the author(s).


Today: HTTPClient


Laurent
laurent laffont laurent laffont
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient


On Sun, Feb 6, 2011 at 6:01 PM, laurent laffont <[hidden email]> wrote:
Comment Of The Day Contest - One Day One Comment
Rules: Each day a not commented class is elected. Each day the best comment will be integrated with name of the author(s).


Today: HTTPClient


I'm a facade for doing simple HTTP GET/POST operations like downloading / uploading some content. 

For example, I get HTML content for http://www.pharo-project.org web page like this: HTTPClient httpGet: 'http://www.pharo-project.org'.


Laurent
 


Laurent

Sven Van Caekenberghe Sven Van Caekenberghe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient


On 06 Feb 2011, at 18:23, laurent laffont wrote:

> I'm a facade for doing simple HTTP GET/POST operations like downloading / uploading some content.
>
> For example, I get HTML content for http://www.pharo-project.org web page like this: HTTPClient httpGet: 'http://www.pharo-project.org'.

I'm a facade for doing simple HTTP GET/POST operations like downloading / uploading some content.

For example, I get HTML content for http://www.pharo-project.org web page like this:

        HTTPClient httpGet: 'http://www.pharo-project.org'.
        HTTPClient httpGetDocument: 'http://www.pharo-project.org'.

When successful, a Stream respectively a MIMEDocument is returned, in case of error, a String is returned.

       
Francisco Ortiz Peñaloza Francisco Ortiz Peñaloza
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient

It would be great to ilustrate post usage as well and delete class
method #examplePostArgs

I'm a facade for doing simple HTTP GET/POST operations like
downloading / uploading some content.

For example, I get HTML content for http://www.pharo-project.org web
page like this:

       HTTPClient httpGet: 'http://www.pharo-project.org'.
       HTTPClient httpGetDocument: 'http://www.pharo-project.org'.

Or, i can make a post request to http://www.pharo-project.org and send
data to the server like this:

        args := Dictionary new.
        args
                at: 'arg1' put: #('val1');
                at: 'arg2' put: #('val2').
        result := HTTPClient httpPostDocument: 'http://www.pharo-project.org'
args: args.

When successful, a Stream respectively a MIMEDocument is returned, in
case of error, a String is returned.

On Sun, Feb 6, 2011 at 5:03 PM, Sven Van Caekenberghe <[hidden email]> wrote:

>
> On 06 Feb 2011, at 18:23, laurent laffont wrote:
>
> > I'm a facade for doing simple HTTP GET/POST operations like downloading / uploading some content.
> >
> > For example, I get HTML content for http://www.pharo-project.org web page like this: HTTPClient httpGet: 'http://www.pharo-project.org'.
>
> I'm a facade for doing simple HTTP GET/POST operations like downloading / uploading some content.
>
> For example, I get HTML content for http://www.pharo-project.org web page like this:
>
>        HTTPClient httpGet: 'http://www.pharo-project.org'.
>        HTTPClient httpGetDocument: 'http://www.pharo-project.org'.
>
> When successful, a Stream respectively a MIMEDocument is returned, in case of error, a String is returned.
>
>

Stéphane Ducasse Stéphane Ducasse
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient

Hi francisco

> It would be great to ilustrate post usage as well and delete class
> method #examplePostArgs

open a ticket.

Stef

>
> I'm a facade for doing simple HTTP GET/POST operations like
> downloading / uploading some content.
>
> For example, I get HTML content for http://www.pharo-project.org web
> page like this:
>
>        HTTPClient httpGet: 'http://www.pharo-project.org'.
>        HTTPClient httpGetDocument: 'http://www.pharo-project.org'.
>
> Or, i can make a post request to http://www.pharo-project.org and send
> data to the server like this:
>
>        args := Dictionary new.
> args
> at: 'arg1' put: #('val1');
> at: 'arg2' put: #('val2').
> result := HTTPClient httpPostDocument: 'http://www.pharo-project.org'
> args: args.
>
> When successful, a Stream respectively a MIMEDocument is returned, in
> case of error, a String is returned.
>
> On Sun, Feb 6, 2011 at 5:03 PM, Sven Van Caekenberghe <[hidden email]> wrote:
>>
>> On 06 Feb 2011, at 18:23, laurent laffont wrote:
>>
>>> I'm a facade for doing simple HTTP GET/POST operations like downloading / uploading some content.
>>>
>>> For example, I get HTML content for http://www.pharo-project.org web page like this: HTTPClient httpGet: 'http://www.pharo-project.org'.
>>
>> I'm a facade for doing simple HTTP GET/POST operations like downloading / uploading some content.
>>
>> For example, I get HTML content for http://www.pharo-project.org web page like this:
>>
>>        HTTPClient httpGet: 'http://www.pharo-project.org'.
>>        HTTPClient httpGetDocument: 'http://www.pharo-project.org'.
>>
>> When successful, a Stream respectively a MIMEDocument is returned, in case of error, a String is returned.
>>
>>
>


Philippe Marschall-2-3 Philippe Marschall-2-3
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient

In reply to this post by laurent laffont
On 06.02.2011 18:01, laurent laffont wrote:
> Comment Of The Day Contest - One Day One Comment
> Rules: Each day a not commented class is elected. Each day the best
> comment will be integrated with name of the author(s).
>
>
> Today: HTTPClient

<trollmode>
I'm a good example of how not to write code. Turn around, walk away,
fast. I'm fully of bugs.

Somebody at some point thought that HTTP is a simple "hacker with
telnet"-protocol. It's not.
</trollmode>

Philippe


Philippe Marschall-2-3 Philippe Marschall-2-3
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient

On 06.02.2011 21:42, Philippe Marschall wrote:

> On 06.02.2011 18:01, laurent laffont wrote:
>> Comment Of The Day Contest - One Day One Comment
>> Rules: Each day a not commented class is elected. Each day the best
>> comment will be integrated with name of the author(s).
>>
>>
>> Today: HTTPClient
>
> <trollmode>
> I'm a good example of how not to write code. Turn around, walk away,
> fast. I'm fully of bugs.
>
> Somebody at some point thought that HTTP is a simple "hacker with
> telnet"-protocol. It's not.
> </trollmode>

That's actually HTTPSocket, not HTTPClient.

Cheers
Philippe


laurent laffont laurent laffont
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient


On Sun, Feb 6, 2011 at 9:44 PM, Philippe Marschall <[hidden email]> wrote:
On 06.02.2011 21:42, Philippe Marschall wrote:
> On 06.02.2011 18:01, laurent laffont wrote:
>> Comment Of The Day Contest - One Day One Comment
>> Rules: Each day a not commented class is elected. Each day the best
>> comment will be integrated with name of the author(s).
>>
>>
>> Today: HTTPClient
>
> <trollmode>
> I'm a good example of how not to write code. Turn around, walk away,
> fast. I'm fully of bugs.
>
> Somebody at some point thought that HTTP is a simple "hacker with
> telnet"-protocol. It's not.
> </trollmode>

That's actually HTTPSocket, not HTTPClient.


Arf, can someone manage the "One Day One Refactoring Contest" ?  :D

Laurent


 

Cheers
Philippe



Stéphane Ducasse Stéphane Ducasse
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient

In reply to this post by Philippe Marschall-2-3
lol

On Feb 6, 2011, at 9:42 PM, Philippe Marschall wrote:

> On 06.02.2011 18:01, laurent laffont wrote:
>> Comment Of The Day Contest - One Day One Comment
>> Rules: Each day a not commented class is elected. Each day the best
>> comment will be integrated with name of the author(s).
>>
>>
>> Today: HTTPClient
>
> <trollmode>
> I'm a good example of how not to write code. Turn around, walk away,
> fast. I'm fully of bugs.
>
> Somebody at some point thought that HTTP is a simple "hacker with
> telnet"-protocol. It's not.
> </trollmode>
>
> Philippe
>
>


Francisco Ortiz Peñaloza Francisco Ortiz Peñaloza
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient

Done, see http://code.google.com/p/pharo/issues/detail?id=3676

On Sun, Feb 6, 2011 at 7:33 PM, Stéphane Ducasse
<[hidden email]> wrote:

> lol
>
> On Feb 6, 2011, at 9:42 PM, Philippe Marschall wrote:
>
>> On 06.02.2011 18:01, laurent laffont wrote:
>>> Comment Of The Day Contest - One Day One Comment
>>> Rules: Each day a not commented class is elected. Each day the best
>>> comment will be integrated with name of the author(s).
>>>
>>>
>>> Today: HTTPClient
>>
>> <trollmode>
>> I'm a good example of how not to write code. Turn around, walk away,
>> fast. I'm fully of bugs.
>>
>> Somebody at some point thought that HTTP is a simple "hacker with
>> telnet"-protocol. It's not.
>> </trollmode>
>>
>> Philippe
>>
>>
>
>
>

Stéphane Ducasse Stéphane Ducasse
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient

tx!!

Stef

On Feb 6, 2011, at 10:52 PM, Francisco Ortiz Peñaloza wrote:

> Done, see http://code.google.com/p/pharo/issues/detail?id=3676
>
> On Sun, Feb 6, 2011 at 7:33 PM, Stéphane Ducasse
> <[hidden email]> wrote:
>> lol
>>
>> On Feb 6, 2011, at 9:42 PM, Philippe Marschall wrote:
>>
>>> On 06.02.2011 18:01, laurent laffont wrote:
>>>> Comment Of The Day Contest - One Day One Comment
>>>> Rules: Each day a not commented class is elected. Each day the best
>>>> comment will be integrated with name of the author(s).
>>>>
>>>>
>>>> Today: HTTPClient
>>>
>>> <trollmode>
>>> I'm a good example of how not to write code. Turn around, walk away,
>>> fast. I'm fully of bugs.
>>>
>>> Somebody at some point thought that HTTP is a simple "hacker with
>>> telnet"-protocol. It's not.
>>> </trollmode>
>>>
>>> Philippe
>>>
>>>
>>
>>
>>
>


Norbert Hartl Norbert Hartl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient

In reply to this post by Philippe Marschall-2-3

On 06.02.2011, at 21:42, Philippe Marschall wrote:

> On 06.02.2011 18:01, laurent laffont wrote:
>> Comment Of The Day Contest - One Day One Comment
>> Rules: Each day a not commented class is elected. Each day the best
>> comment will be integrated with name of the author(s).
>>
>>
>> Today: HTTPClient
>
> <trollmode>
> I'm a good example of how not to write code. Turn around, walk away,
> fast. I'm fully of bugs.
>
> Somebody at some point thought that HTTP is a simple "hacker with
> telnet"-protocol. It's not.
> </trollmode>
>
I had something comparable on my mind but did let it go. I appreciate you didn't :)

Norbert


Sven Van Caekenberghe Sven Van Caekenberghe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [COTDC] 3 - HTTPClient

In reply to this post by Francisco Ortiz Peñaloza
I'm a facade for doing simple HTTP GET/POST operations like downloading / uploading some content.

For example, I get HTML content for http://www.pharo-project.org web page like this:

       HTTPClient httpGet: 'http://www.pharo-project.org'.
       HTTPClient httpGetDocument: 'http://www.pharo-project.org'.

When successful, a Stream respectively a MIMEDocument is returned, in case of error, a String is returned.

Or, I can make a application/x-www-form-urlencoded post request to http://intranet.acme.com/login and send form data to the server like this:

       (args := Dictionary new)
                at: 'username' put: #('[hidden email]');
                at: 'password' put: #('secretpassword').
        result := HTTPClient httpPostDocument: 'http://intranet.acme.com/login' args: args.

Alternatively, I can do a multipart/formdata post request to http://intranet.acme.com/files and send a file like this:

       (args := Dictionary new)
                at: 'file' put: (Array with: (MIMEDocument contents: 'This is a test' mimeType: 'text/plain' uri: 'file:///test.txt').
        result := HTTPClient httpPostDocument: 'http://intranet.acme.com/files' args: args.

On 06 Feb 2011, at 20:25, Francisco Ortiz Peñaloza wrote:

> I'm a facade for doing simple HTTP GET/POST operations like
> downloading / uploading some content.
>
> For example, I get HTML content for http://www.pharo-project.org web
> page like this:
>
>        HTTPClient httpGet: 'http://www.pharo-project.org'.
>        HTTPClient httpGetDocument: 'http://www.pharo-project.org'.
>
> Or, i can make a post request to http://www.pharo-project.org and send
> data to the server like this:
>
>        args := Dictionary new.
> args
> at: 'arg1' put: #('val1');
> at: 'arg2' put: #('val2').
> result := HTTPClient httpPostDocument: 'http://www.pharo-project.org'
> args: args.
>
> When successful, a Stream respectively a MIMEDocument is returned, in
> case of error, a String is returned.


Sven Van Caekenberghe Sven Van Caekenberghe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [SPAM] Re: [COTDC] 3 - HTTPClient

In reply to this post by Philippe Marschall-2-3

On 06 Feb 2011, at 21:44, Philippe Marschall wrote:

>> <trollmode>
>> I'm a good example of how not to write code. Turn around, walk away,
>> fast. I'm fully of bugs.
>>
>> Somebody at some point thought that HTTP is a simple "hacker with
>> telnet"-protocol. It's not.
>> </trollmode>
>
> That's actually HTTPSocket, not HTTPClient.

Although it is a negative comment, it is the truth.

Still, adding some comments and lowering the pain for others is still a good idea.

Sven
Stéphane Ducasse Stéphane Ducasse
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [SPAM] Re: [COTDC] 3 - HTTPClient

:)
We should just merge the two :)


>>> <trollmode>
>>> I'm a good example of how not to write code. Turn around, walk away,
>>> fast. I'm fully of bugs.
>>>
>>> Somebody at some point thought that HTTP is a simple "hacker with
>>> telnet"-protocol. It's not.
>>> </trollmode>
>>
>> That's actually HTTPSocket, not HTTPClient.
>
> Although it is a negative comment, it is the truth.
>
> Still, adding some comments and lowering the pain for others is still a good idea.
>
> Sven


laurent laffont laurent laffont
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [SPAM] Re: [COTDC] 3 - HTTPClient


Laurent


On Mon, Feb 7, 2011 at 4:33 PM, Stéphane Ducasse <[hidden email]> wrote:
:)
We should just merge the two :)


>>> <trollmode>
>>> I'm a good example of how not to write code. Turn around, walk away,
>>> fast. I'm fully of bugs.
>>>
>>> Somebody at some point thought that HTTP is a simple "hacker with
>>> telnet"-protocol. It's not.
>>> </trollmode>
>>
>> That's actually HTTPSocket, not HTTPClient.
>
> Although it is a negative comment, it is the truth.
>
> Still, adding some comments and lowering the pain for others is still a good idea.
>
> Sven



Stéphane Ducasse Stéphane Ducasse
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [SPAM] Re: [COTDC] 3 - HTTPClient

I added the comment with the troll :)

On Feb 7, 2011, at 6:21 PM, laurent laffont wrote:

> FYI I put results here: http://code.google.com/p/pharo/wiki/CommentOfTheDayContest
>
> Laurent
>
>
> On Mon, Feb 7, 2011 at 4:33 PM, Stéphane Ducasse <[hidden email]> wrote:
> :)
> We should just merge the two :)
>
>
> >>> <trollmode>
> >>> I'm a good example of how not to write code. Turn around, walk away,
> >>> fast. I'm fully of bugs.
> >>>
> >>> Somebody at some point thought that HTTP is a simple "hacker with
> >>> telnet"-protocol. It's not.
> >>> </trollmode>
> >>
> >> That's actually HTTPSocket, not HTTPClient.
> >
> > Although it is a negative comment, it is the truth.
> >
> > Still, adding some comments and lowering the pain for others is still a good idea.
> >
> > Sven
>
>
>


Luc Fabresse Luc Fabresse
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [SPAM] Re: [COTDC] 3 - HTTPClient

In reply to this post by laurent laffont


2011/2/7 laurent laffont <[hidden email]>

Thanks Laurent.
It is a really great because it document the system and I learn a lot at the same time ;-)

#Luc

 

Laurent


On Mon, Feb 7, 2011 at 4:33 PM, Stéphane Ducasse <[hidden email]> wrote:
:)
We should just merge the two :)


>>> <trollmode>
>>> I'm a good example of how not to write code. Turn around, walk away,
>>> fast. I'm fully of bugs.
>>>
>>> Somebody at some point thought that HTTP is a simple "hacker with
>>> telnet"-protocol. It's not.
>>> </trollmode>
>>
>> That's actually HTTPSocket, not HTTPClient.
>
> Although it is a negative comment, it is the truth.
>
> Still, adding some comments and lowering the pain for others is still a good idea.
>
> Sven




Dmitri Zagidulin Dmitri Zagidulin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [SPAM] Re: [COTDC] 3 - HTTPClient

Actually, can somebody explain the troll-mode comment? Why is the
HTTPClient an example of how not to write code? Should we not be using
this package in production? What does the comment about  "hacker with
telnet"-protocol mean?

On Mon, Feb 7, 2011 at 2:12 PM, Luc Fabresse <[hidden email]> wrote:

>
>
> 2011/2/7 laurent laffont <[hidden email]>
>>
>> FYI I put results
>> here: http://code.google.com/p/pharo/wiki/CommentOfTheDayContest
>
> Thanks Laurent.
> It is a really great because it document the system and I learn a lot at the
> same time ;-)
> #Luc
>
>>
>> Laurent
>>
>> On Mon, Feb 7, 2011 at 4:33 PM, Stéphane Ducasse
>> <[hidden email]> wrote:
>>>
>>> :)
>>> We should just merge the two :)
>>>
>>>
>>> >>> <trollmode>
>>> >>> I'm a good example of how not to write code. Turn around, walk away,
>>> >>> fast. I'm fully of bugs.
>>> >>>
>>> >>> Somebody at some point thought that HTTP is a simple "hacker with
>>> >>> telnet"-protocol. It's not.
>>> >>> </trollmode>
>>> >>
>>> >> That's actually HTTPSocket, not HTTPClient.
>>> >
>>> > Although it is a negative comment, it is the truth.
>>> >
>>> > Still, adding some comments and lowering the pain for others is still a
>>> > good idea.
>>> >
>>> > Sven
>>>
>>>
>>
>
>

Stéphane Ducasse Stéphane Ducasse
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [SPAM] Re: [COTDC] 3 - HTTPClient

this is more HTTPSocket
I'm sure that philippe will love to answer :)

Stef


On Feb 7, 2011, at 8:23 PM, Dmitri Zagidulin wrote:

> Actually, can somebody explain the troll-mode comment? Why is the
> HTTPClient an example of how not to write code? Should we not be using
> this package in production? What does the comment about  "hacker with
> telnet"-protocol mean?
>
> On Mon, Feb 7, 2011 at 2:12 PM, Luc Fabresse <[hidden email]> wrote:
>>
>>
>> 2011/2/7 laurent laffont <[hidden email]>
>>>
>>> FYI I put results
>>> here: http://code.google.com/p/pharo/wiki/CommentOfTheDayContest
>>
>> Thanks Laurent.
>> It is a really great because it document the system and I learn a lot at the
>> same time ;-)
>> #Luc
>>
>>>
>>> Laurent
>>>
>>> On Mon, Feb 7, 2011 at 4:33 PM, Stéphane Ducasse
>>> <[hidden email]> wrote:
>>>>
>>>> :)
>>>> We should just merge the two :)
>>>>
>>>>
>>>>>>> <trollmode>
>>>>>>> I'm a good example of how not to write code. Turn around, walk away,
>>>>>>> fast. I'm fully of bugs.
>>>>>>>
>>>>>>> Somebody at some point thought that HTTP is a simple "hacker with
>>>>>>> telnet"-protocol. It's not.
>>>>>>> </trollmode>
>>>>>>
>>>>>> That's actually HTTPSocket, not HTTPClient.
>>>>>
>>>>> Although it is a negative comment, it is the truth.
>>>>>
>>>>> Still, adding some comments and lowering the pain for others is still a
>>>>> good idea.
>>>>>
>>>>> Sven
>>>>
>>>>
>>>
>>
>>
>


12
Loading...