diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2019-06-03 21:07:55 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2019-06-03 21:07:55 +0200 |
commit | 23e09bc8bf0a8a7b00703220b3fff4a0d084d4fe (patch) | |
tree | 330db0d5871babf6d6529a35fafba2c70e41b808 /src | |
parent | 0486d666810e58c356ed507bb6ee2366b32ab06e (diff) | |
download | twister-23e09bc8bf0a8a7b00703220b3fff4a0d084d4fe.tar.gz twister-23e09bc8bf0a8a7b00703220b3fff4a0d084d4fe.tar.bz2 twister-23e09bc8bf0a8a7b00703220b3fff4a0d084d4fe.zip |
5724: remove duplications.
Diffstat (limited to 'src')
-rw-r--r-- | src/twister/taler-twister-service.c | 97 |
1 files changed, 25 insertions, 72 deletions
diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c index 7247daa..af2551b 100644 --- a/src/twister/taler-twister-service.c +++ b/src/twister/taler-twister-service.c @@ -1516,11 +1516,15 @@ create_response (void *cls, } /* No need to check whether we're POSTing or PUTting. - * If not needed, this value will just be ignored.*/ + * If not needed, one of the following values will be + * ignored.*/ curl_easy_setopt (hr->curl, CURLOPT_POSTFIELDSIZE, hr->io_len); curl_easy_setopt (hr->curl, + CURLOPT_INFILESIZE, + hr->io_len); + curl_easy_setopt (hr->curl, CURLOPT_HEADERFUNCTION, &curl_check_hdr); curl_easy_setopt (hr->curl, @@ -1544,6 +1548,22 @@ create_response (void *cls, curl_easy_setopt (hr->curl, CURLOPT_VERBOSE, 0); + + curl_easy_setopt (hr->curl, + CURLOPT_READFUNCTION, + &curl_upload_cb); + + curl_easy_setopt (hr->curl, + CURLOPT_READDATA, + hr); + + curl_easy_setopt (hr->curl, + CURLOPT_WRITEFUNCTION, + &curl_download_cb); + + curl_easy_setopt (hr->curl, + CURLOPT_WRITEDATA, + hr); { char *curlurl; @@ -1559,6 +1579,7 @@ create_response (void *cls, curlurl); GNUNET_free (curlurl); } + if (0 == strcasecmp (meth, MHD_HTTP_METHOD_PUT)) { @@ -1566,38 +1587,11 @@ create_response (void *cls, "Crafting a CURL PUT request\n"); curl_easy_setopt (hr->curl, - CURLOPT_UPLOAD, + CURLOPT_PUT, 1L); - curl_easy_setopt (hr->curl, - CURLOPT_READFUNCTION, - &curl_upload_cb); + hr->state = REQUEST_STATE_PROXY_UPLOAD_STARTED; - curl_easy_setopt (hr->curl, - CURLOPT_READDATA, - hr); - { - const char *us; - long upload_size; - - us = MHD_lookup_connection_value - (con, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_CONTENT_LENGTH); - - if ( (1 == sscanf (us, - "%ld", - &upload_size)) && - (upload_size >= 0) ) - curl_easy_setopt (hr->curl, - CURLOPT_INFILESIZE, - upload_size); - } - curl_easy_setopt (hr->curl, - CURLOPT_WRITEFUNCTION, - &curl_download_cb); - curl_easy_setopt (hr->curl, - CURLOPT_WRITEDATA, - hr); + } else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_POST)) @@ -1613,42 +1607,7 @@ create_response (void *cls, CURLOPT_VERBOSE, 1L); hr->state = REQUEST_STATE_PROXY_UPLOAD_STARTED; - GNUNET_assert - (CURLE_OK == curl_easy_setopt - (hr->curl, - CURLOPT_READFUNCTION, - &curl_upload_cb)); - - curl_easy_setopt (hr->curl, - CURLOPT_READDATA, - hr); - { - const char *us; - long upload_size; - - us = MHD_lookup_connection_value - (con, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_CONTENT_LENGTH); - - if ( (1 == sscanf (us, - "%ld", - &upload_size)) && - (upload_size >= 0) ) - { - curl_easy_setopt (hr->curl, - CURLOPT_INFILESIZE, - upload_size); - } - } - - curl_easy_setopt (hr->curl, - CURLOPT_WRITEFUNCTION, - &curl_download_cb); - curl_easy_setopt (hr->curl, - CURLOPT_WRITEDATA, - hr); } else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_HEAD)) @@ -1673,12 +1632,6 @@ create_response (void *cls, curl_easy_setopt (hr->curl, CURLOPT_HTTPGET, 1L); - curl_easy_setopt (hr->curl, - CURLOPT_WRITEFUNCTION, - &curl_download_cb); - curl_easy_setopt (hr->curl, - CURLOPT_WRITEDATA, - hr); } else { |