/* DLL */
struct ProxyREMatch *prev;
+ /* is SSL */
+ int is_ssl;
+
/* hostname found */
char hostname[255];
memcpy (new_value, pdata->value, pdata->total_bytes);
memcpy (new_value+off, data, size);
GNUNET_free (pdata->value);
+ pdata->value = new_value;
pdata->total_bytes += size;
return MHD_YES;
char* hdr_val;
int delta_cdomain;
size_t offset = 0;
+ char cors_hdr[strlen (ctask->leho) + strlen ("https://")];
if (NULL == ctask->response)
{
&mhd_content_cb,
ctask,
NULL);
+
+ /* if we have a leho add a CORS header */
+ if (0 != strcmp ("", ctask->leho))
+ {
+ /* We could also allow ssl and http here */
+ if (ctask->mhd->is_ssl)
+ sprintf (cors_hdr, "https://%s", ctask->leho);
+ else
+ sprintf (cors_hdr, "http://%s", ctask->leho);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "MHD: Adding CORS header field %s\n",
+ cors_hdr);
+
+ if (GNUNET_NO == MHD_add_response_header (ctask->response,
+ "Access-Control-Allow-Origin",
+ cors_hdr))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "MHD: Error adding CORS header field %s\n",
+ cors_hdr);
+ }
+ }
ctask->ready_to_queue = GNUNET_YES;
-
}
if (html_mime_len <= bytes)
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct ProxyCurlTask *ctask = cls;
- GNUNET_assert (NULL == ctask->pp_match_head);
+ struct ProxyUploadData *pdata;
+ GNUNET_assert (NULL == ctask->pp_match_head);
if (NULL != ctask->headers)
curl_slist_free_all (ctask->headers);
if (NULL != ctask->post_handler)
MHD_destroy_post_processor (ctask->post_handler);
+ if (GNUNET_SCHEDULER_NO_TASK != ctask->pp_task)
+ GNUNET_SCHEDULER_cancel (ctask->pp_task);
+ for (pdata = ctask->upload_data_head; NULL != pdata; pdata = ctask->upload_data_head)
+ {
+ GNUNET_CONTAINER_DLL_remove (ctask->upload_data_head,
+ ctask->upload_data_tail,
+ pdata);
+ GNUNET_free_non_null (pdata->filename);
+ GNUNET_free_non_null (pdata->content_type);
+ GNUNET_free_non_null (pdata->key);
+ GNUNET_free_non_null (pdata->value);
+ GNUNET_free (pdata);
+ }
GNUNET_free (ctask);
}
size_t max)
{
struct ProxyCurlTask *ctask = cls;
- struct ProxyREMatch *re_match = ctask->pp_match_head;
+ struct ProxyREMatch *re_match;
ssize_t copied = 0;
long long int bytes_to_copy = ctask->buffer_write_ptr - ctask->buffer_read_ptr;
return 0;
copied = 0;
- for (; NULL != re_match; re_match = ctask->pp_match_head)
+ for (re_match = ctask->pp_match_head; NULL != re_match; re_match = ctask->pp_match_head)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"MHD: Processing PP %s\n",
return copied;
}
+
/**
* Shorten result callback
*
re_match->hostname,
result);
- if (re_match->ctask->mhd->is_ssl)
+ if (re_match->is_ssl)
sprintf (re_match->result, "href=\"https://%s", result);
else
sprintf (re_match->result, "href=\"http://%s", result);
memset (re_hostname, 0, sizeof (re_hostname));
memcpy (re_hostname, re_ptr+m[1].rm_so, (m[3].rm_eo-m[1].rm_so));
+
re_match = GNUNET_malloc (sizeof (struct ProxyREMatch));
re_match->start = re_ptr + m[0].rm_so;
re_match->end = re_ptr + m[3].rm_eo;
re_match->done = GNUNET_NO;
re_match->ctask = ctask;
+
+ if ('s' == *(re_ptr+m[1].rm_so-strlen("://")-1)) //FIXME strcmp
+ re_match->is_ssl = GNUNET_YES;
+ else
+ re_match->is_ssl = GNUNET_NO;
+
strcpy (re_match->hostname, re_hostname);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"PP: Got hostname %s\n", re_hostname);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Running curl tasks: %d\n", running);
- ctask = ctasks_head;
- for (; ctask != NULL; ctask = ctask->next)
+ for (ctask = ctasks_head; NULL != ctask; ctask = ctask->next)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"CTask: %s\n", ctask->url);
do
{
- ctask = ctasks_head;
+
msg = curl_multi_info_read (curl_multi, &msgnum);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Messages left: %d\n", msgnum);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Download curl failed");
- for (; ctask != NULL; ctask = ctask->next)
+ for (ctask = ctasks_head; NULL != ctask; ctask = ctask->next)
{
if (NULL == ctask->curl)
continue;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"CURL: download completed.\n");
- for (; ctask != NULL; ctask = ctask->next)
+ for (ctask = ctasks_head; NULL != ctask; ctask = ctask->next)
{
if (NULL == ctask->curl)
continue;
}
} while (msgnum > 0);
- for (ctask=clean_head; ctask != NULL; ctask = ctask->next)
+ for (ctask=clean_head; NULL != ctask; ctask = ctask->next)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"CURL: Removing task %s.\n", ctask->url);
}
num_ctasks=0;
- for (ctask=ctasks_head; ctask != NULL; ctask = ctask->next)
+ for (ctask=ctasks_head; NULL != ctask; ctask = ctask->next)
{
num_ctasks++;
}
curl_download_prepare();
}
+
/**
* Process LEHO lookup
*
curl_easy_setopt (ctask->curl, CURLOPT_TIMEOUT, 600L);
/* Add GNS header */
- //ctask->headers = curl_slist_append (ctask->headers,
- // "GNS: YES");
+ ctask->headers = curl_slist_append (ctask->headers,
+ "GNS: YES");
ctask->accepted = GNUNET_YES;
ctask->download_in_progress = GNUNET_YES;
ctask->buf_status = BUF_WAIT_FOR_CURL;
{
if (GNUNET_YES == ctask->is_httppost)
{
- i = 0;
for (upload_data_iter = ctask->upload_data_head;
NULL != upload_data_iter;
upload_data_iter = upload_data_iter->next)
{
+ i = 0;
if (NULL != upload_data_iter->filename)
{
forms[i].option = CURLFORM_FILENAME;
0, "DE", 2);
gnutls_x509_crt_set_dn_by_oid (request, GNUTLS_OID_X520_ORGANIZATION_NAME,
- 0, "GNUnet", 6);
+ 0, "GADS", 4);
gnutls_x509_crt_set_dn_by_oid (request, GNUTLS_OID_X520_COMMON_NAME,
0, name, strlen (name));
struct NetworkHandleList *tmp_nh;
struct ProxyCurlTask *ctask;
struct ProxyCurlTask *ctask_tmp;
+ struct ProxyUploadData *pdata;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Shutting down...\n");
if (NULL != ctask->response)
MHD_destroy_response (ctask->response);
- //FIXME free pdata here
+ pdata = ctask->upload_data_head;
+ //FIXME free pdata here
+ for (; pdata != NULL; pdata = ctask->upload_data_head)
+ {
+ GNUNET_CONTAINER_DLL_remove (ctask->upload_data_head,
+ ctask->upload_data_tail,
+ pdata);
+ GNUNET_free_non_null (pdata->filename);
+ GNUNET_free_non_null (pdata->content_type);
+ GNUNET_free_non_null (pdata->key);
+ GNUNET_free_non_null (pdata->value);
+ GNUNET_free (pdata);
+ }
GNUNET_free (ctask);
}