[drakma-devel] Problem abouth POST HTTP request

Nicolas Lamirault lam at tuxfamily.org
Tue Sep 18 11:55:39 UTC 2007


thanks for your response.

Ralf Mattes <rm at seid-online.de> writes:

> Hi, just some quick shots into the dark ...
>
> On Tue, 2007-09-18 at 13:23 +0200, Nicolas Lamirault wrote:
>> hi,
>> i've got this request :
>> 
>> $> curl --data '{"author":"nicolas"}' http://localhost:8888/test -H "application/json"
>> {"ok":true,"_id":"C97DCFBF09D32461D60F0D30BF3E807C","_rev":555997582}% 
>
> Is this _really_ the command line you use? Shouldn't this read
>
>  ... -H 'Content-Type: application/json" ... ?

i try this, and i've got the right result :

* curl -v --data '{"author":"nicolas"}' http://localhost:8888/test
* About to connect() to localhost port 8888
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8888
> POST /test HTTP/1.1
> User-Agent: curl/7.15.5 (i486-pc-linux-gnu) libcurl/7.15.5
> OpenSSL/0.9.8c zlib/1.2.3 libidn/0.6.5
> Host: localhost:8888
> Accept: */*
> Content-Length: 20
> Content-Type: application/x-www-form-urlencoded
> 
> {"author":"nicolas"}HTTP/1.1 201 Created
< Server: inets/develop
< Date: Tue, 18 Sep 2007 11:53:10 GMT
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: Tue, 18 Sep 2007 11:53:10 GMT
< Damien: awesome
< Content-Type: text/plain; charset=utf-8
< Transfer-Encoding: chunked
< X-Couch-Id: 2FC290BA0DB5B1DDB1BE10EBB671C3A0
< X-Couch-Rev: -1041032725
* Connection #0 to host localhost left intact
* Closing connection #0
{"ok":true,"_id":"2FC290BA0DB5B1DDB1BE10EBB671C3A0","_rev":-1041032725}% 


> I guess you server implementation isn't too picky/stable/wel--programmed
> and blindly reads the request data anyway :-/
>
>> i would like to make the same request using Drakma :
>> 
>> CL-USER> (drakma:http-request "http://localhost:8888/test"
>>                               :method :post
>>                               :form-data t
>>                               :external-format-out :UTF-8
>>                               :parameters '(("author" . "nicolas")))
>
> But this will send the request data formated as multipart/form-data and
> of course the toy-parser will hickup un that. What do you expect?

i would like a http code 200 and a result like this :

{"ok":true, "_id":".....", "_rev":xxxxx}



> HTH RalfD
>
> (hoping Edi's server will accept my mail ...)
>
>> POST /test HTTP/1.1
>> Host: localhost:8888
>> User-Agent: Drakma/0.9.1 (SBCL 1.0; Linux; 2.6.15-23-686; http://weitz.de/drakma/)
>> Accept: */*
>> Connection: close
>> Content-Type: multipart/form-data; boundary=----------sUTYSe7i1UX7ONyEB68U4BbXyx2TZYZ0x1Qmx4vCVWyI9Bpb92
>> Content-Length: 188
>> 
>> HTTP/1.1 500 Internal Server Error
>> Server: inets/develop
>> Date: Tue, 18 Sep 2007 10:54:03 GMT
>> Cache-Control: no-cache
>> Pragma: no-cache
>> Expires: Tue, 18 Sep 2007 10:54:03 GMT
>> Damien: awesome
>> Content-Type: text/plain; charset=utf-8
>> Transfer-Encoding: chunked
>> Connection:close
>> 
>> "{\"error\":{\"id\":\"EXIT\",\"reason\":\"{function_clause,[{cjson,tokenize_number,[[45,45,45,45,45,45,45,45,45,45,45,115,85,84,89,83,101,55,105,49,85,88,55,79,78,121,69,66,54,56,85,52,66,98,88,121,120,50,84,90,89,90,48,120,49,81,109,120,52,118,67,86,87,121,73,57,66,112,98,57,50,13,10,67,111,110,116,101,110,116,45,68,105,115,112,111,115,105,116,105,111,110,58,32,102,111,114,109,45,100,97,116,97,59,32,110,97,109,101,61,34,97,117,116,104,111,114,34,13,10,13,10,110,105,99,111,108,97,115,13,10,45,45,45,45,45,45,45,45,45,45,45,45,115,85,84,89,83,101,55,105,49,85,88,55,79,78,121,69,66,54,56,85,52,66,98,88,121,120,50,84,90,89,90,48,120,49,81,109,120,52,118,67,86,87,121,73,57,66,112,98,57,50,45,45,13,10],int,{decoder,utf8,null,1,2,any},[45]]},{cjson,tokenize,2},{cjson,decode1,2},{cjson,json_decode,2},{mod_couch,handle_db_request,3},{mod_couch,do,1},{httpd_response,traverse_modules,2},{httpd_response,generate_and_send_response,1}]}\"}}"
>> 500
>> ((:SERVER . "inets/develop") (:DATE . "Tue, 18 Sep 2007 10:54:03 GMT")
>>  (:CACHE-CONTROL . "no-cache") (:PRAGMA . "no-cache")
>>  (:EXPIRES . "Tue, 18 Sep 2007 10:54:03 GMT") (:DAMIEN . "awesome")
>>  (:CONTENT-TYPE  .  "text/plain;  charset=utf-8")  (:TRANSFER-ENCODING
>>  . "chunked")
>>  (:CONNECTION . "close"))
>> #<PURI:URI http://localhost:8888/test>
>> #<FLEXI-STREAMS:FLEXI-IO-STREAM {BFB70A1}>
>> T
>> "Internal Server Error"
>> 
>> 
>> i've got an error code 500. Due to a bad request i think. Someon knows
>> what error i did in this request ?
>> 
>> thanks.
>> 
>> 
>
> _______________________________________________
> drakma-devel mailing list
> drakma-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel
>

-- 
Nicolas Lamirault



More information about the Drakma-devel mailing list