diff options
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 6b4a1c0d5..3f28f420a 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -772,6 +772,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls) | |||
772 | char* hdr_val; | 772 | char* hdr_val; |
773 | int delta_cdomain; | 773 | int delta_cdomain; |
774 | size_t offset = 0; | 774 | size_t offset = 0; |
775 | char cors_hdr[strlen (ctask->leho) + strlen ("https://")]; | ||
775 | 776 | ||
776 | if (NULL == ctask->response) | 777 | if (NULL == ctask->response) |
777 | { | 778 | { |
@@ -783,8 +784,30 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls) | |||
783 | &mhd_content_cb, | 784 | &mhd_content_cb, |
784 | ctask, | 785 | ctask, |
785 | NULL); | 786 | NULL); |
787 | |||
788 | /* if we have a leho add a CORS header */ | ||
789 | if (0 != strcmp ("", ctask->leho)) | ||
790 | { | ||
791 | /* We could also allow ssl and http here */ | ||
792 | if (ctask->mhd->is_ssl) | ||
793 | sprintf (cors_hdr, "https://%s", ctask->leho); | ||
794 | else | ||
795 | sprintf (cors_hdr, "http://%s", ctask->leho); | ||
796 | |||
797 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
798 | "MHD: Adding CORS header field %s\n", | ||
799 | cors_hdr); | ||
800 | |||
801 | if (GNUNET_NO == MHD_add_response_header (ctask->response, | ||
802 | "Access-Control-Allow-Origin", | ||
803 | cors_hdr)) | ||
804 | { | ||
805 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
806 | "MHD: Error adding CORS header field %s\n", | ||
807 | cors_hdr); | ||
808 | } | ||
809 | } | ||
786 | ctask->ready_to_queue = GNUNET_YES; | 810 | ctask->ready_to_queue = GNUNET_YES; |
787 | |||
788 | } | 811 | } |
789 | 812 | ||
790 | if (html_mime_len <= bytes) | 813 | if (html_mime_len <= bytes) |