I am building a Riak NoSQL database project which uses http as the interface. I now have all of the Riak methods working so I can add buckets/key:value pairs, amend them, retrieve them and delete them plus all the other thing that it allows you to do. I can't publish this as I have built it around our own Totally Objects SocketSet socket manager (you would need to buy it to get the Riak library to work - unless you already have it, though..
-- To enable me to make it available, I need to shift all of the http calls to WinHttp - although that won't satisfy the Linux market :-(. The problem is that I can't make head nor tail WinHttp and can't see where to get started. Can anyone show me the Smalltalk for a standard GET and POST? You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout.
David
Totally Objects Doing Smalltalk since 1989 |
I would start with making a subclass of SstHttpClient and then from that you have most of the stuff you need ... Marten Am Samstag, 7. Mai 2016 20:41:21 UTC+2 schrieb Totally Objects:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Long Haired David
OK, went there and got all of my GET operations sorted using the fetch methods in SstHttpClient. However, I have a problem with the post methods. All of them fail with the same error.
-- UndefinedObject does not understand transport The code is here in SstHttpClient: newTransportMessage ^localEndpoint transport configuration messageClass new localEndPoint is properly initialised in the fetch methods but not in the post. I can't figure out what to do next. Any thoughts? On Saturday, May 7, 2016 at 7:41:21 PM UTC+1, Totally Objects wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout.
David
Totally Objects Doing Smalltalk since 1989 |
Perhaps you can write a very small example how you call the httpclient ?
-- Marten Am Sonntag, 8. Mai 2016 16:36:43 UTC+2 schrieb Totally Objects:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Long Haired David
This is my call for a standard get
-- | fetch | fetch := (SstHttpClient fetch: 'http://www.totallyobjects.com'). self halt. ^ fetch contents reference That's it. But, when using a PUT, I get an error from localEndpoint which is an instance variable without a setter that I can see. David On Saturday, May 7, 2016 at 7:41:21 PM UTC+1, Totally Objects wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout.
David
Totally Objects Doing Smalltalk since 1989 |
David
-- fetch: sends a GET. PUT is not implemented in SstHttpClient. but it's not too hard... newMsg := SstByteMessage new. newMsg header: (SstHttpRequestHeader new command: 'PUT'; url: url; version: HttpVersion11; contentLength: 0; host: url ; yourself). and then you can use an SstHttpClient instance to send: newMsg to: aUrl That's basically it. On a side note: I wish Instantiations brushed the dust off the Sst frameworks to make things easier and support all (or at least the most important) HTTP methods with an easy API. But before that, a lot of global state and stuff has to be removed from Sst.. it's really hard to work with the HTTP clients and servers and such, just because the code is really ugly and dusty. It constantly fetches some info from some more or less global variable instead of just providing methods/parameters to just pass this info in. Same is true for SMTP and stuff... Unnecessarily hard to detangle... Joachim Am Dienstag, 10. Mai 2016 21:36:35 UTC+2 schrieb Totally Objects:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Long Haired David
Thanks for the help but Nope. I don't get it. Here is my code (with false data so don't try this - my Riak database is open so I can't publish the access details).
-- It still stops in SstHttpClient basicSend:to:ignoringResponseContent: at this point (remoteEndpoint := localEndpoint send: httpMessage to: remoteEndpoint) isSstError because localEndpoint is still not initialised. riakSstPost: aString content: content Suppose the URL is http://totallyobjects.com and it is listening on port 8098. Suppose that I am trying to put a JSON = '{""nickname"" : ""Henry"", ""breed"" : ""Golden Retriever""}' into a bucket called 'myAnimals'. Suppose that the data to be sent is as follows: | newMsg url host content path| content := '''{""nickname"" : ""Henry"", ""breed"" : ""Golden Retriever""}'''. path := '/riak/myAnimals/Henry/'. url := SstIpUrl fromString: 'http://totallyobjects.com:8098',path,content.. host := SstIpUrl fromString: 'http://totallyobjects.com:8098'. newMsg := SstByteMessage new. newMsg header: (SstHttpRequestHeader new command: 'PUT'; url: url; version: 'HttpVersion11'; contentLength: 0; host: host ; yourself). SstHttpClient new send: newMsg to: host On Saturday, May 7, 2016 at 7:41:21 PM UTC+1, Totally Objects wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout.
David
Totally Objects Doing Smalltalk since 1989 |
In reply to this post by Long Haired David
Just to be clear, you can run this piece of code - it will never connect because there is no riak server on the end at totallyobjects.com but it will progress far enough to throw the error I am talking about. | newMsg url host json path | json := '''{""nickname"" : ""Henry"", ""breed"" : ""Golden Retriever""}'''. path := '/riak/myAnimals/Henry/'. url := SstIpUrl fromString: 'http://totallyobjects.com:8098',path,json.. host := SstIpUrl fromString: 'http://totallyobjects.com:8098'. newMsg := SstByteMessage new. newMsg header: (SstHttpRequestHeader new command: 'PUT'; url: url; version: 'HttpVersion11'; contentLength: 0; host: host ; yourself). SstHttpClient new send: newMsg to: host You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout.
David
Totally Objects Doing Smalltalk since 1989 |
Though not tested, I would try something like: | url json tmpClient |-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
I noticed, that your example used PUT. Well - subclass SstHttpClient and add support for PUT there. You may look at the code how POST has been implemented ... Marten Marten Feldtmann <[hidden email]> hat am 12. Mai 2016 um 11:19 geschrieben:
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
That worked fine. Many thanks Marten. Just thinking - you and I - must be 20 years now?
-- David Totally Objects On Thursday, May 12, 2016 at 10:22:50 AM UTC+1, Marten Feldtmann wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout.
David
Totally Objects Doing Smalltalk since 1989 |
Am 12.05.2016 um 13:32 schrieb Totally Objects:
> That worked fine. Many thanks Marten. Just thinking - you and I - must > be 20 years now? Well, around 18 years now - starting 1998 with VASmalltalk 4.02 ... :-) -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Happy days!
-- On Thursday, May 12, 2016 at 12:36:30 PM UTC+1, Marten Feldtmann wrote: Am 12.05.2016 um 13:32 schrieb Totally Objects: You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at https://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout.
David
Totally Objects Doing Smalltalk since 1989 |
Free forum by Nabble | Edit this page |