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: #('[email protected]'); 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.
