654{
655 json_t *json;
656 char *ct;
657
658#if DEBUG
660 "Downloaded body: %.*s\n",
663#endif
664 if (CURLE_OK !=
665 curl_easy_getinfo (eh,
666 CURLINFO_RESPONSE_CODE,
667 response_code))
668 {
669
671 *response_code = 0;
672 }
674 return NULL;
675 if ((CURLE_OK !=
676 curl_easy_getinfo (eh,
677 CURLINFO_CONTENT_TYPE,
678 &ct)) ||
679 (NULL == ct) ||
681 {
682
683
684 if (0 !=
db->buf_size)
685 {
686 const char *url;
687
688 if (CURLE_OK !=
689 curl_easy_getinfo (eh,
690 CURLINFO_EFFECTIVE_URL,
691 &url))
692 url = "<unknown URL>";
694 "Request to `%s' was expected to return a body of type `application/json', got `%s'\n",
695 url,
696 ct);
697 }
698 return NULL;
699 }
700 if (0 == *response_code)
701 {
702 const char *url;
703
704 if (CURLE_OK !=
705 curl_easy_getinfo (eh,
706 CURLINFO_EFFECTIVE_URL,
707 &url))
708 url = "<unknown URL>";
710 "Failed to download response from `%s': \n",
711 url);
712 return NULL;
713 }
714 json = NULL;
716 {
717 json_error_t error;
718
719 json = json_loadb (
db->buf,
721 JSON_REJECT_DUPLICATES | JSON_DISABLE_EOF_CHECK,
722 &error);
723 if (NULL == json)
724 {
726 *response_code = 0;
728 "Failed to parse JSON response: %s\n",
729 error.text);
730 }
731 }
735 return json;
736}
static bool is_json(const char *ct)
Test if the given content type ct is JSON.
#define JSON_WARN(error)
Print JSON parsing related error information.
static struct GNUNET_FS_DirectoryBuilder * db
#define GNUNET_log(kind,...)
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
@ MHD_HTTP_NO_CONTENT
No Content [RFC7231, Section 6.3.5].