setting a custom header for HTTP via CurlPlugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

setting a custom header for HTTP via CurlPlugin

heinsaris
Hi,

I am trying to get some stuff done with REST using Pharo.
So far, I am able to do GETs, but I am unable to do PUTs because the REST service expects the content sent to be JSON.
For this to work, I need to set the Content-Type of the request to 'application/json'.
I have successfully installed the CurlPlugin via Gofer (version 25 from dao), and thanks to John (M. McIntosh), who provided me with a new version of the bundle for Mac, I was able to pass all the tests, except for the testApiOptions test, which fails on the timeout: test.
The version John provided me with is 2.0.0. I first tried with version 1.1.0, but that failed on 13 tests due to a primitive that failed constantly (<primitive: 'primSetOptLong' module: 'CurlPlugin'>).
 There is a method addHeader: in the plugin, but it does not seem to do anything useful.

I have found a blog (Jazz Programming) by Giovanni Corriga, who claims to have a version of the plugin that allows for custom headers to be set, but the link to his version gives a 304 error. Plus the blog dates from 2007.

Having a version of the CurlPlugin that allows me to set a custom header would be great, so if anybody has one, please let me know. But what I would really like to have is a good implementation of the HTTP protocol in Squeak/Pharo, so that we are not dependent on a plugin. The standard HTTP client in Squeak/Pharo is based on HttpSocket, and is only a partial implementation of the HTTP protocol (it only supports GETs as far as I can tell).

Does anyone know of another way to do basic HTTP in Squeak/Pharo?

Regards,

Hein






_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: setting a custom header for HTTP via CurlPlugin

Stéphane Ducasse

On Apr 21, 2010, at 1:48 PM, Saris Hein wrote:

> Hi,
>
> I am trying to get some stuff done with REST using Pharo.
> So far, I am able to do GETs, but I am unable to do PUTs because the REST service expects the content sent to be JSON.
> For this to work, I need to set the Content-Type of the request to 'application/json'.
> I have successfully installed the CurlPlugin via Gofer (version 25 from dao), and thanks to John (M. McIntosh), who provided me with a new version of the bundle for Mac, I was able to pass all the tests, except for the testApiOptions test, which fails on the timeout: test.
> The version John provided me with is 2.0.0. I first tried with version 1.1.0, but that failed on 13 tests due to a primitive that failed constantly (<primitive: 'primSetOptLong' module: 'CurlPlugin'>).
> There is a method addHeader: in the plugin, but it does not seem to do anything useful.
>
> I have found a blog (Jazz Programming) by Giovanni Corriga, who claims to have a version of the plugin that allows for custom headers to be set, but the link to his version gives a 304 error. Plus the blog dates from 2007.
>
> Having a version of the CurlPlugin that allows me to set a custom header would be great, so if anybody has one, please let me know. But what I would really like to have is a good implementation of the HTTP protocol in Squeak/Pharo, so that we are not dependent on a plugin.

me too.
Did you discuss with janko?
Because he was proposing a project on exactly this topic.


> The standard HTTP client in Squeak/Pharo is based on HttpSocket, and is only a partial implementation of the HTTP protocol (it only supports GETs as far as I can tell).
>
> Does anyone know of another way to do basic HTTP in Squeak/Pharo?
>
> Regards,
>
> Hein
>
>
>
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: setting a custom header for HTTP via CurlPlugin

fstephany
The Cloudfork (amazon web services wrappers) guys propose two options:
- SWHTTPClient
- CurlPlugin

I've never tested the former one, but you'll maybe find what you need ?
http://code.google.com/p/cloudfork/wiki/InstallingForSqueak

>> Having a version of the CurlPlugin that allows me to set a custom header would be great, so if anybody has one, please let me know. But what I would really like to have is a good implementation of the HTTP protocol in Squeak/Pharo, so that we are not dependent on a plugin.
>
> me too.
> Did you discuss with janko?
> Because he was proposing a project on exactly this topic.


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: setting a custom header for HTTP via CurlPlugin

Igor Stasenko
In reply to this post by heinsaris
On 21 April 2010 14:48, Saris Hein <[hidden email]> wrote:

> Hi,
>
> I am trying to get some stuff done with REST using Pharo.
> So far, I am able to do GETs, but I am unable to do PUTs because the REST service expects the content sent to be JSON.
> For this to work, I need to set the Content-Type of the request to 'application/json'.
> I have successfully installed the CurlPlugin via Gofer (version 25 from dao), and thanks to John (M. McIntosh), who provided me with a new version of the bundle for Mac, I was able to pass all the tests, except for the testApiOptions test, which fails on the timeout: test.
> The version John provided me with is 2.0.0. I first tried with version 1.1.0, but that failed on 13 tests due to a primitive that failed constantly (<primitive: 'primSetOptLong' module: 'CurlPlugin'>).
>  There is a method addHeader: in the plugin, but it does not seem to do anything useful.
>
> I have found a blog (Jazz Programming) by Giovanni Corriga, who claims to have a version of the plugin that allows for custom headers to be set, but the link to his version gives a 304 error. Plus the blog dates from 2007.
>
> Having a version of the CurlPlugin that allows me to set a custom header would be great, so if anybody has one, please let me know. But what I would really like to have is a good implementation of the HTTP protocol in Squeak/Pharo, so that we are not dependent on a plugin. The standard HTTP client in Squeak/Pharo is based on HttpSocket, and is only a partial implementation of the HTTP protocol (it only supports GETs as far as I can tell).
>
> Does anyone know of another way to do basic HTTP in Squeak/Pharo?
>

Yes. I know :)
Another way is to use sockets directly, without curl. This is way what
i went for implementing a CouchDB interface for Pharo & Squeak. With
this way you can generate _any_ request header with any contents,
without bothering, if some 3rd party plugin supports it or not.
You can check it out here:

MCHttpRepository
    location: 'http://www.squeaksource.com/SCouchDB'
    user: ''
    password: ''



> Regards,
>
> Hein
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project