[Pharo-project] [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
On Sun, Feb 6, 2011 at 6:01 PM, laurent laffont <laurent.laffont@gmail.com>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
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.
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 <sven@beta9.be> 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.
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 <sven@beta9.be> 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.
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: #('john@acme.com'); 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.
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
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
On Sun, Feb 6, 2011 at 9:44 PM, Philippe Marschall <kustos@gmx.net> 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
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
:) 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
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 <stephane.ducasse@inria.fr>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
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 <stephane.ducasse@inria.fr> 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
2011/2/7 laurent laffont <laurent.laffont@gmail.com>
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 < stephane.ducasse@inria.fr> 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
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 <luc.fabresse@gmail.com> wrote:
2011/2/7 laurent laffont <laurent.laffont@gmail.com>
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 <stephane.ducasse@inria.fr> 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
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 <luc.fabresse@gmail.com> wrote:
2011/2/7 laurent laffont <laurent.laffont@gmail.com>
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 <stephane.ducasse@inria.fr> 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
Haha, Perhaps there should also be a rating for class comments ... G, PG, R, NSFW... Dale On 02/07/2011 12:07 PM, Stéphane Ducasse wrote:
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<luc.fabresse@gmail.com> wrote:
2011/2/7 laurent laffont<laurent.laffont@gmail.com>
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 <stephane.ducasse@inria.fr> 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
On Mon, Feb 7, 2011 at 9:52 PM, Dale Henrichs <dhenrich@vmware.com> wrote:
Haha,
Perhaps there should also be a rating for class comments ... G, PG, R, NSFW...
We can vote on 1st March to deliver the "Best Comment Of The Month" Award :) Laurent
Dale
On 02/07/2011 12:07 PM, Stéphane Ducasse wrote:
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<luc.fabresse@gmail.com> wrote:
2011/2/7 laurent laffont<laurent.laffont@gmail.com>
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 <stephane.ducasse@inria.fr> 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
On 07 Feb 2011, at 20:23, 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?
Well have a look at, for example, HTTPSocket class>>#httpGetDocument:args:accept:request: or HTTPSocket class>>#httpPostDocument:args:accept:request: Apart from the fact that, externally, the interface is at the same time too big and too small, this is just an enormeous procedural piece of code, without any object oriented structuring at all, let alone reusability. Furthermore, although it works more or less, it is incomplete and bloated at the same time. Nobody dares to touch it. But please, go have a look yourself ;-) Sven
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
Done, see http://code.google.com/p/pharo/issues/detail?id=3676 On Sun, Feb 6, 2011 at 7:33 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> 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
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 <stephane.ducasse@inria.fr> 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
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
participants (9)
-
Dale Henrichs -
Dmitri Zagidulin -
Francisco Ortiz Peñaloza -
laurent laffont -
Luc Fabresse -
Norbert Hartl -
Philippe Marschall -
Stéphane Ducasse -
Sven Van Caekenberghe