cetcd icon indicating copy to clipboard operation
cetcd copied to clipboard

Issue when set contains large value

Open kinsu opened this issue 8 years ago • 4 comments

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);

  • struct curl_slist *chunk = NULL;
  • chunk = curl_slist_append(chunk, "Expect:");
  • res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);

res = curl_easy_perform(curl);

  • curl_slist_free_all(chunk);

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

kinsu avatar Sep 04 '16 19:09 kinsu

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

shafreeck avatar Sep 05 '16 10:09 shafreeck

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

kinsu avatar Sep 05 '16 16:09 kinsu

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

shafreeck avatar Sep 19 '16 02:09 shafreeck

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

zhileitao avatar Nov 22 '16 01:11 zhileitao