shafreeck / cetcd

Cetcd is a C client library for etcd with full features support
Apache License 2.0
69 stars 39 forks source link

Issue when set contains large value #37

Open kinsu opened 8 years ago

kinsu commented 8 years ago

it appears that when value of the key is large (something larger than 1024 or so) Expect: 100-continue is used from libcurl (if i can recall by defult) and state machine is troubled(response_discard_st). etcd replies with HTTP/1.1 100 Continue and then HTTP/1.1 200 OK.

error :1000, not a json response (HTTP/1.1 200 OK ) Error Code:1000 Error Message:not a json response Error Cause:HTTP/1.1 200 OK

One possible workarround is the disable the Expect: 100-continue in the send request

@@ -1122,9 +1129,15 @@ void cetcd_send_request(CURL curl, cetcd_request *req) { curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cetcd_parse_response); curl_easy_setopt(curl, CURLOPT_VERBOSE, req->cli->settings.verbose); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, req->cli->settings.connect_timeout);

if that's OK i can send a pull request.

shafreeck commented 8 years ago

What would happen when 100 Continue is disabled on large value ?

kinsu commented 8 years ago

then cetcd will send the full payload towards etcd (100-continue will not be returned from etcd)

shafreeck commented 8 years ago

Sorry for my late reply. It looks good to me. Please send me a pull request if you will.

zhileitao commented 7 years ago

In this case with larger value string, it's libcurl initiated the "expect 100-continue). Disable it should works. Theoretically, other 1xx like 102-processing may be received as indicated by HTTP protocal. So is it better to add cetcd_parse_response() the capability to handle the 1xx msg? Just for open discussion. 1xx is informational response from server which should be discard by cetcd if any of they received. 1×× Informational 100 Continue 101 Switching Protocols 102 Processing