title: Unsupported Protocol using Curl in C
body: <p>I am currently working on a project that requires using C to make an http get request. I am trying to do this using curl. However, I get a response that says</p>
  
  <pre><code>error: unable to request data from https://coinex.pw/api/v2/currencies:
  Unsupported protocol
  </code></pre>
  
  <p>I am not sure if the error is coming from curl or from the server. Here is my code, borrowed from example code:</p>
  
  <pre><code>#include &lt;curl/curl.h&gt;
  
  static char *request(const char *url)
  {
  CURL *curl = NULL;
  CURLcode status;
  struct curl_slist *headers = NULL;
  char *data = NULL;
  long code;
  
  curl_global_init(CURL_GLOBAL_ALL);
  curl = curl_easy_init();
  if(!curl)
      goto error;
  
  data = malloc(BUFFER_SIZE);
  if(!data)
      goto error;
  
  struct write_result write_result = {
      .data = data,
      .pos = 0
  };
  
  curl_easy_setopt(curl, CURLOPT_URL, url);
  
  headers = curl_slist_append(headers, "Content-type: application/json");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_response);
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, &amp;write_result);
  
  status = curl_easy_perform(curl);
  if(status != 0)
  {
      fprintf(stderr, "error: unable to request data from %s:\n", url);
      fprintf(stderr, "%s\n", curl_easy_strerror(status));
      goto error;
  }
  
  curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &amp;code);
  if(code != 200)
  {
      fprintf(stderr, "error: server responded with code %ld\n", code);
      goto error;
  }
  
  curl_easy_cleanup(curl);
  curl_slist_free_all(headers);
  curl_global_cleanup();
  
  /* zero-terminate the result */
  data[write_result.pos] = '\0';
  
  return data;
  
  error:
  if(data)
      free(data);
  if(curl)
      curl_easy_cleanup(curl);
  if(headers)
      curl_slist_free_all(headers);
  curl_global_cleanup();
  return NULL;
  }
  </code></pre>
  
  <p>Any tips / hints are welcome.</p>