aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-07-13 21:17:24 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-07-13 21:17:24 +0000
commit1e6e1afe150c62f99473facfa7d67054b18f0c4e (patch)
tree6c05e360565dbf7dd5b6e7472cc18b1cc802890b
parentd83d4a5b98f35790d84231a6b0124a3ccf0af21f (diff)
downloadgnunet-1e6e1afe150c62f99473facfa7d67054b18f0c4e.tar.gz
gnunet-1e6e1afe150c62f99473facfa7d67054b18f0c4e.zip
-rip timeout issue
-rw-r--r--src/gns/gnunet-gns-proxy.c194
1 files changed, 120 insertions, 74 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 69c02774b..48f162239 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -273,6 +273,10 @@ struct ProxyCurlTask
273 273
274 /* connection */ 274 /* connection */
275 struct MHD_Connection *connection; 275 struct MHD_Connection *connection;
276
277 /*put*/
278 size_t put_read_offset;
279 size_t put_read_size;
276 280
277}; 281};
278 282
@@ -610,24 +614,11 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
610 offset++; 614 offset++;
611 } 615 }
612 616
613 //memcpy (new_cookie_hdr+offset, tok, strlen (tok));
614
615 GNUNET_free (ndup); 617 GNUNET_free (ndup);
616 618
617 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 619 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
618 "Got Set-Cookie HTTP header %s\n", new_cookie_hdr); 620 "Got Set-Cookie HTTP header %s\n", new_cookie_hdr);
619 621
620 //pch = GNUNET_malloc (sizeof (struct ProxySetCookieHeader));
621 //len = strlen (hdr_cookie) - cookie_hdr_len - 1;
622 //pch->cookie = GNUNET_malloc (len + 1);
623 //memset (pch->cookie, 0, len + 1);
624 //memcpy (pch->cookie, hdr_cookie+cookie_hdr_len+1, len);
625 //GNUNET_CONTAINER_DLL_insert (ctask->set_cookies_head,
626 // ctask->set_cookies_tail,
627 // pch);
628 //pch = ctask->set_cookies_head;
629 //while (pch != NULL)
630 //{
631 if (GNUNET_NO == MHD_add_response_header (ctask->response, 622 if (GNUNET_NO == MHD_add_response_header (ctask->response,
632 MHD_HTTP_HEADER_SET_COOKIE, 623 MHD_HTTP_HEADER_SET_COOKIE,
633 new_cookie_hdr)) 624 new_cookie_hdr))
@@ -637,40 +628,39 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls)
637 hdr_generic+cookie_hdr_len+1); 628 hdr_generic+cookie_hdr_len+1);
638 } 629 }
639 return bytes; 630 return bytes;
640 //GNUNET_free (pch->cookie);
641 //GNUNET_CONTAINER_DLL_remove (ctask->set_cookies_head,
642 // ctask->set_cookies_tail,
643 // pch);
644 //GNUNET_free (pch);
645 //pch = ctask->set_cookies_head;
646 //}
647 } 631 }
648 632
649 ndup = GNUNET_strdup (hdr_generic); 633 ndup = GNUNET_strdup (hdr_generic);
650 hdr_type = strtok (ndup, ":"); 634 hdr_type = strtok (ndup, ":");
651 635
652 if (hdr_type != NULL) 636 if (NULL == hdr_type)
653 { 637 {
654 hdr_val = strtok (NULL, ""); 638 GNUNET_free (ndup);
655 if (hdr_val != NULL) 639 return bytes;
656 {
657 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
658 "Trying to set %s: %s\n",
659 hdr_type,
660 hdr_val+1);
661 if (GNUNET_NO == MHD_add_response_header (ctask->response,
662 hdr_type,
663 hdr_val+1))
664 {
665 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
666 "MHD: Error adding %s header field %s\n",
667 hdr_type,
668 hdr_val+1);
669 }
670 }
671 } 640 }
672 GNUNET_free (ndup);
673 641
642 hdr_val = strtok (NULL, "");
643
644 if (NULL == hdr_val)
645 {
646 GNUNET_free (ndup);
647 return bytes;
648 }
649
650 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
651 "Trying to set %s: %s\n",
652 hdr_type,
653 hdr_val+1);
654 if (GNUNET_NO == MHD_add_response_header (ctask->response,
655 hdr_type,
656 hdr_val+1))
657 {
658 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
659 "MHD: Error adding %s header field %s\n",
660 hdr_type,
661 hdr_val+1);
662 }
663 GNUNET_free (ndup);
674 return bytes; 664 return bytes;
675} 665}
676 666
@@ -777,7 +767,7 @@ mhd_content_cb (void *cls,
777 (0 == bytes_to_copy) && 767 (0 == bytes_to_copy) &&
778 (BUF_WAIT_FOR_CURL == ctask->buf_status)) 768 (BUF_WAIT_FOR_CURL == ctask->buf_status))
779 { 769 {
780 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 770 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
781 "MHD: sending response for %s\n", ctask->url); 771 "MHD: sending response for %s\n", ctask->url);
782 ctask->download_in_progress = GNUNET_NO; 772 ctask->download_in_progress = GNUNET_NO;
783 run_mhd_now (ctask->mhd); 773 run_mhd_now (ctask->mhd);
@@ -791,7 +781,7 @@ mhd_content_cb (void *cls,
791 (0 == bytes_to_copy) && 781 (0 == bytes_to_copy) &&
792 (BUF_WAIT_FOR_CURL == ctask->buf_status)) 782 (BUF_WAIT_FOR_CURL == ctask->buf_status))
793 { 783 {
794 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 784 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
795 "MHD: sending error response\n"); 785 "MHD: sending error response\n");
796 ctask->download_in_progress = GNUNET_NO; 786 ctask->download_in_progress = GNUNET_NO;
797 run_mhd_now (ctask->mhd); 787 run_mhd_now (ctask->mhd);
@@ -856,7 +846,7 @@ mhd_content_cb (void *cls,
856 return copied; 846 return copied;
857 } 847 }
858 848
859 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 849 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
860 "MHD: Adding PP result %s to buffer\n", 850 "MHD: Adding PP result %s to buffer\n",
861 re_match->result); 851 re_match->result);
862 memcpy (buf+copied, re_match->result, strlen (re_match->result)); 852 memcpy (buf+copied, re_match->result, strlen (re_match->result));
@@ -870,7 +860,7 @@ mhd_content_cb (void *cls,
870 860
871 bytes_to_copy = ctask->buffer_write_ptr - ctask->buffer_read_ptr; 861 bytes_to_copy = ctask->buffer_write_ptr - ctask->buffer_read_ptr;
872 862
873 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
874 "MHD: copied: %d left: %d, space left in buf: %d\n", 864 "MHD: copied: %d left: %d, space left in buf: %d\n",
875 copied, 865 copied,
876 bytes_to_copy, max-copied); 866 bytes_to_copy, max-copied);
@@ -879,7 +869,7 @@ mhd_content_cb (void *cls,
879 869
880 if (GNUNET_NO == ctask->download_is_finished) 870 if (GNUNET_NO == ctask->download_is_finished)
881 { 871 {
882 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 872 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
883 "MHD: Purging buffer\n"); 873 "MHD: Purging buffer\n");
884 memmove (ctask->buffer, ctask->buffer_read_ptr, bytes_to_copy); 874 memmove (ctask->buffer, ctask->buffer_read_ptr, bytes_to_copy);
885 ctask->buffer_read_ptr = ctask->buffer; 875 ctask->buffer_read_ptr = ctask->buffer;
@@ -898,9 +888,6 @@ mhd_content_cb (void *cls,
898 copied += bytes_to_copy; 888 copied += bytes_to_copy;
899 ctask->buf_status = BUF_WAIT_FOR_CURL; 889 ctask->buf_status = BUF_WAIT_FOR_CURL;
900 890
901 //if ((NULL != ctask->curl) &&
902 // (GNUNET_NO == ctask->download_is_finished) &&
903 // ((ctask->buffer_write_ptr - ctask->buffer_read_ptr) <= 0))
904 if (NULL != ctask->curl) 891 if (NULL != ctask->curl)
905 curl_easy_pause (ctask->curl, CURLPAUSE_CONT); 892 curl_easy_pause (ctask->curl, CURLPAUSE_CONT);
906 893
@@ -924,7 +911,7 @@ process_shorten (void* cls, const char* short_name)
924 911
925 if (NULL == short_name) 912 if (NULL == short_name)
926 { 913 {
927 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 914 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
928 "PP: Unable to shorten %s\n", 915 "PP: Unable to shorten %s\n",
929 re_match->hostname); 916 re_match->hostname);
930 GNUNET_CONTAINER_DLL_remove (re_match->ctask->pp_match_head, 917 GNUNET_CONTAINER_DLL_remove (re_match->ctask->pp_match_head,
@@ -939,11 +926,11 @@ process_shorten (void* cls, const char* short_name)
939 else 926 else
940 strcpy (result, short_name); 927 strcpy (result, short_name);
941 928
942 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
943 "PP: Shorten %s -> %s\n", 930 "PP: Shorten %s -> %s\n",
944 re_match->hostname, 931 re_match->hostname,
945 result); 932 result);
946 //this is evil.. what about https 933
947 if (re_match->ctask->mhd->is_ssl) 934 if (re_match->ctask->mhd->is_ssl)
948 sprintf (re_match->result, "href=\"https://%s", result); 935 sprintf (re_match->result, "href=\"https://%s", result);
949 else 936 else
@@ -955,8 +942,10 @@ process_shorten (void* cls, const char* short_name)
955 942
956 943
957/** 944/**
958 * Tabula Rasa postprocess buffer 945 * Postprocess data in buffer. From read ptr to write ptr
959 * 946 *
947 * @param cls the curlproxytask
948 * @param tc task context
960 */ 949 */
961static void 950static void
962postprocess_buffer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 951postprocess_buffer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -971,20 +960,20 @@ postprocess_buffer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
971 960
972 if (GNUNET_YES != ctask->parse_content) 961 if (GNUNET_YES != ctask->parse_content)
973 { 962 {
974 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 963 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
975 "PP: Not parsing content\n"); 964 "PP: Not parsing content\n");
976 ctask->buf_status = BUF_WAIT_FOR_MHD; 965 ctask->buf_status = BUF_WAIT_FOR_MHD;
977 run_mhd_now (ctask->mhd); 966 run_mhd_now (ctask->mhd);
978 return; 967 return;
979 } 968 }
980 969
981 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
982 "PP: We need to parse the HTML\n"); 971 "PP: We need to parse the HTML\n");
983 972
984 /* 0 means match found */ 973 /* 0 means match found */
985 while (0 == regexec (&re_dotplus, re_ptr, RE_N_MATCHES, m, 0)) 974 while (0 == regexec (&re_dotplus, re_ptr, RE_N_MATCHES, m, 0))
986 { 975 {
987 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
988 "PP: regex match\n"); 977 "PP: regex match\n");
989 978
990 GNUNET_assert (m[1].rm_so != -1); 979 GNUNET_assert (m[1].rm_so != -1);
@@ -994,14 +983,12 @@ postprocess_buffer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
994 983
995 re_match = GNUNET_malloc (sizeof (struct ProxyREMatch)); 984 re_match = GNUNET_malloc (sizeof (struct ProxyREMatch));
996 re_match->start = re_ptr + m[0].rm_so; 985 re_match->start = re_ptr + m[0].rm_so;
997 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
998 "XXXXX: %d\n", re_match->start);
999 re_match->end = re_ptr + m[3].rm_eo; 986 re_match->end = re_ptr + m[3].rm_eo;
1000 re_match->done = GNUNET_NO; 987 re_match->done = GNUNET_NO;
1001 re_match->ctask = ctask; 988 re_match->ctask = ctask;
1002 strcpy (re_match->hostname, re_hostname); 989 strcpy (re_match->hostname, re_hostname);
1003 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 990 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1004 "Got hostname %s\n", re_hostname); 991 "PP: Got hostname %s\n", re_hostname);
1005 re_ptr += m[3].rm_eo; 992 re_ptr += m[3].rm_eo;
1006 993
1007 if (GNUNET_YES == is_tld (re_match->hostname, GNUNET_GNS_TLD_PLUS)) 994 if (GNUNET_YES == is_tld (re_match->hostname, GNUNET_GNS_TLD_PLUS))
@@ -1025,14 +1012,19 @@ postprocess_buffer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1025 } 1012 }
1026 1013
1027 ctask->buf_status = BUF_WAIT_FOR_MHD; 1014 ctask->buf_status = BUF_WAIT_FOR_MHD;
1028 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1015 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1029 "PP: No more matches\n"); 1016 "PP: No more matches\n");
1030 run_mhd_now (ctask->mhd); 1017 run_mhd_now (ctask->mhd);
1031} 1018}
1032 1019
1033/** 1020/**
1034 * Tabula Rasa cURL download 1021 * Handle data from cURL
1035 * 1022 *
1023 * @param ptr pointer to the data
1024 * @param size number of blocks of data
1025 * @param nmemb blocksize
1026 * @param ctx the curlproxytask
1027 * @return number of bytes handled
1036 */ 1028 */
1037static size_t 1029static size_t
1038curl_download_cb (void *ptr, size_t size, size_t nmemb, void* ctx) 1030curl_download_cb (void *ptr, size_t size, size_t nmemb, void* ctx)
@@ -1043,7 +1035,7 @@ curl_download_cb (void *ptr, size_t size, size_t nmemb, void* ctx)
1043 size_t buf_space = sizeof (ctask->buffer) - 1035 size_t buf_space = sizeof (ctask->buffer) -
1044 (ctask->buffer_write_ptr-ctask->buffer); 1036 (ctask->buffer_write_ptr-ctask->buffer);
1045 1037
1046 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1038 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1047 "CURL: Got %d. %d free in buffer\n", 1039 "CURL: Got %d. %d free in buffer\n",
1048 total, buf_space); 1040 total, buf_space);
1049 1041
@@ -1051,7 +1043,7 @@ curl_download_cb (void *ptr, size_t size, size_t nmemb, void* ctx)
1051 { 1043 {
1052 if (ctask->buf_status == BUF_WAIT_FOR_CURL) 1044 if (ctask->buf_status == BUF_WAIT_FOR_CURL)
1053 { 1045 {
1054 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1046 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1055 "CURL: Buffer full starting postprocessing\n"); 1047 "CURL: Buffer full starting postprocessing\n");
1056 ctask->buf_status = BUF_WAIT_FOR_PP; 1048 ctask->buf_status = BUF_WAIT_FOR_PP;
1057 ctask->pp_task = GNUNET_SCHEDULER_add_now (&postprocess_buffer, 1049 ctask->pp_task = GNUNET_SCHEDULER_add_now (&postprocess_buffer,
@@ -1072,7 +1064,6 @@ curl_download_cb (void *ptr, size_t size, size_t nmemb, void* ctx)
1072 ctask->buffer_write_ptr += total; 1064 ctask->buffer_write_ptr += total;
1073 ctask->buffer_write_ptr[0] = '\0'; 1065 ctask->buffer_write_ptr[0] = '\0';
1074 1066
1075 //run_mhd_now (ctask->mhd);
1076 return total; 1067 return total;
1077} 1068}
1078 1069
@@ -1134,11 +1125,21 @@ curl_download_prepare ()
1134 if (curl_download_task != GNUNET_SCHEDULER_NO_TASK) 1125 if (curl_download_task != GNUNET_SCHEDULER_NO_TASK)
1135 GNUNET_SCHEDULER_cancel (curl_download_task); 1126 GNUNET_SCHEDULER_cancel (curl_download_task);
1136 1127
1137 curl_download_task = 1128 if (-1 != max)
1138 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 1129 {
1139 rtime, 1130 curl_download_task =
1140 grs, gws, 1131 GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1141 &curl_task_download, curl_multi); 1132 rtime,
1133 grs, gws,
1134 &curl_task_download, curl_multi);
1135 }
1136 else if (NULL != ctasks_head)
1137 {
1138 /* as specified in curl docs */
1139 curl_download_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
1140 &curl_task_download,
1141 curl_multi);
1142 }
1142 GNUNET_NETWORK_fdset_destroy (gws); 1143 GNUNET_NETWORK_fdset_destroy (gws);
1143 GNUNET_NETWORK_fdset_destroy (grs); 1144 GNUNET_NETWORK_fdset_destroy (grs);
1144 1145
@@ -1170,7 +1171,7 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1170 1171
1171 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1172 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1172 { 1173 {
1173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1174 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1174 "Shutdown requested while trying to download\n"); 1175 "Shutdown requested while trying to download\n");
1175 //TODO cleanup 1176 //TODO cleanup
1176 return; 1177 return;
@@ -1266,7 +1267,7 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1266 continue; 1267 continue;
1267 1268
1268 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1269 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1269 "CURL: task %s found.\n", ctask->url); 1270 "CURL: completed task %s found.\n", ctask->url);
1270 if (CURLE_OK == curl_easy_getinfo (ctask->curl, 1271 if (CURLE_OK == curl_easy_getinfo (ctask->curl,
1271 CURLINFO_RESPONSE_CODE, 1272 CURLINFO_RESPONSE_CODE,
1272 &resp_code)) 1273 &resp_code))
@@ -1282,7 +1283,7 @@ curl_task_download (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1282 ctask); 1283 ctask);
1283 } 1284 }
1284 1285
1285 //ctask->ready_to_queue = MHD_YES; 1286 ctask->ready_to_queue = MHD_YES;
1286 ctask->download_is_finished = GNUNET_YES; 1287 ctask->download_is_finished = GNUNET_YES;
1287 1288
1288 //GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd); 1289 //GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd);
@@ -1518,18 +1519,21 @@ create_response (void *cls,
1518 struct ProxyCurlTask *ctask; 1519 struct ProxyCurlTask *ctask;
1519 1520
1520 //FIXME handle 1521 //FIXME handle
1521 if (0 != strcasecmp (meth, MHD_HTTP_METHOD_GET)) 1522 if ((0 != strcasecmp (meth, MHD_HTTP_METHOD_GET)) &&
1523 (0 != strcasecmp (meth, MHD_HTTP_METHOD_PUT)) &&
1524 (0 != strcasecmp (meth, MHD_HTTP_METHOD_POST)))
1522 { 1525 {
1523 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1526 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1524 "MHD: %s NOT IMPLEMENTED!\n", meth); 1527 "MHD: %s NOT IMPLEMENTED!\n", meth);
1525 return MHD_NO; 1528 return MHD_NO;
1526 } 1529 }
1527 1530
1528 if (0 != *upload_data_size)
1529 return MHD_NO;
1530 1531
1531 if (NULL == *con_cls) 1532 if (NULL == *con_cls)
1532 { 1533 {
1534
1535 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1536 "Got %s request for %s\n", meth, url);
1533 ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask)); 1537 ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask));
1534 ctask->mhd = hd; 1538 ctask->mhd = hd;
1535 *con_cls = ctask; 1539 *con_cls = ctask;
@@ -1565,6 +1569,48 @@ create_response (void *cls,
1565 MHD_HEADER_KIND, 1569 MHD_HEADER_KIND,
1566 &con_val_iter, ctask); 1570 &con_val_iter, ctask);
1567 1571
1572 if (0 == strcasecmp (meth, MHD_HTTP_METHOD_PUT))
1573 {
1574 if (0 == *upload_data_size)
1575 {
1576 curl_easy_cleanup (ctask->curl);
1577 GNUNET_free (ctask);
1578 return MHD_NO;
1579 }
1580 ctask->put_read_offset = 0;
1581 ctask->put_read_size = *upload_data_size;
1582 curl_easy_setopt (ctask->curl, CURLOPT_UPLOAD, 1);
1583 curl_easy_setopt (ctask->curl, CURLOPT_READDATA, upload_data);
1584 //curl_easy_setopt (ctask->curl, CURLOPT_READFUNCTION, &curl_read_cb);
1585
1586 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1587 "Got PUT data: %s\n", upload_data);
1588 curl_easy_cleanup (ctask->curl);
1589 GNUNET_free (ctask);
1590 return MHD_NO;
1591 }
1592
1593 if (0 == strcasecmp (meth, MHD_HTTP_METHOD_POST))
1594 {
1595 if (0 == *upload_data_size)
1596 {
1597 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1598 "NO data for post!\n");
1599 curl_easy_cleanup (ctask->curl);
1600 GNUNET_free (ctask);
1601 return MHD_NO;
1602 }
1603 curl_easy_setopt (ctask->curl, CURLOPT_POST, 1);
1604 curl_easy_setopt (ctask->curl, CURLOPT_POSTFIELDSIZE, *upload_data_size);
1605 curl_easy_setopt (ctask->curl, CURLOPT_COPYPOSTFIELDS, upload_data);
1606
1607 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1608 "Got POST data: %s\n", upload_data);
1609 curl_easy_cleanup (ctask->curl);
1610 GNUNET_free (ctask);
1611 return MHD_NO;
1612 }
1613
1568 curl_easy_setopt (ctask->curl, CURLOPT_HEADERFUNCTION, &curl_check_hdr); 1614 curl_easy_setopt (ctask->curl, CURLOPT_HEADERFUNCTION, &curl_check_hdr);
1569 curl_easy_setopt (ctask->curl, CURLOPT_HEADERDATA, ctask); 1615 curl_easy_setopt (ctask->curl, CURLOPT_HEADERDATA, ctask);
1570 curl_easy_setopt (ctask->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb); 1616 curl_easy_setopt (ctask->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb);