If I add some data using the protobufs interface, can I retrieve that data
over HTTP? I'm getting an error when I try to GET the id but the return_body
looks proper.

=============================================
import socket
from struct import *
import riakclient_pb2

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 8087))

request = riakclient_pb2.RpbPutReq()
request.bucket = 'test'
request.key = '1'
request.content.value = '{"foo":"bar"}'
request.return_body = True

data = request.SerializeToString()
msg_len = len(data)

s.send(pack('!lb%is' % msg_len, msg_len + 1, 11, data))

(length, code) = unpack('!lb', s.recv(5))
pbm = s.recv(length-1)
s.close()

resp = riakclient_pb2.RpbPutResp()
resp.ParseFromString(pbm)
print 'Return Body:', resp.contents[0].value
=============================================

egau...@deus:(src)$ python riakclient.py
Return Body: {"foo":"bar"}

=============================================
egau...@deus:(src)$ curl -v -H "Content-Type: application/json"
http://127.0.0.1:8098/riak/test/1
* About to connect() to 127.0.0.1 port 8098 (#0)
*   Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8098 (#0)
> GET /riak/test/1 HTTP/1.1
> User-Agent: curl/7.19.4 (universal-apple-darwin10.0) libcurl/7.19.4
OpenSSL/0.9.8l zlib/1.2.3
> Host: 127.0.0.1:8098
> Accept: */*
> Content-Type: application/json
>
< HTTP/1.1 500 Internal Server Error
< Server: MochiWeb/1.1 WebMachine/1.6 (eat around the stinger)
< Date: Wed, 21 Apr 2010 03:41:25 GMT
< Content-Type: text/html
< Content-Length: 1430
<
<html><head><title>500 Internal Server
Error</title></head><body><h1>Internal Server Error</h1>The server
encountered an error while processing this
request:<br><pre>[{webmachine_decision_core,'-decision/1-lc$^1/1-1-',
     [{error,
          {error,badarg,
              [{dict,fetch,
                   [<<"content-type">>,
                    {dict,2,16,16,8,80,48,
                        {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                        {{[],[],[],[],[],[],[],[],[],[],
                          [[<<"X-Riak-VTag">>,52,70,122,120,114,66,87,55,51,
                            105,99,74,114,50,86,89,72,122,101,55,70,82]],
                          [],[],

 [[<<"X-Riak-Last-Modified">>|{1271,821233,40580}]],
                          [],[]}}}]},
               {riak_kv_wm_raw,content_types_provided,2},
               {webmachine_resource,resource_call,3},
               {webmachine_resource,do,3},
               {webmachine_decision_core,resource_call,1},
               {webmachine_decision_core,decision,1},
               {webmachine_decision_core,handle_request,2},
               {webmachine_mochiweb,loop,1}]}}]},
 {webmachine_decision_core,decision,1},
 {webmachine_decision_core,handle_request,2},
 {webmachine_mochiweb,loop,1},
 {mochiweb_http,headers,5},
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
 {proc_lib,init_p_do_apply,3}]</pre><P><HR><ADDRESS>mochiweb+webmachine web
server</ADDRESS></body></html>
=================================================

-Eric
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to