comparison src/curl/curl.c @ 707:88d78a61a9fb trunk

[svn] - proxy support. somebody test this.
author nenolod
date Sat, 24 Feb 2007 08:09:24 -0800
parents fdae06cbebc9
children 9684a1b4e494
comparison
equal deleted inserted replaced
706:6bc134eec1f3 707:88d78a61a9fb
20 # include "config.h" 20 # include "config.h"
21 #endif 21 #endif
22 22
23 #include <audacious/vfs.h> 23 #include <audacious/vfs.h>
24 #include <audacious/plugin.h> 24 #include <audacious/plugin.h>
25 #include <audacious/configdb.h>
25 26
26 #include <curl/curl.h> 27 #include <curl/curl.h>
27 28
28 #include <string.h> 29 #include <string.h>
29 30
545 curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYPEER, 0); 546 curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYPEER, 0);
546 curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYHOST, 0); 547 curl_easy_setopt(handle->curl, CURLOPT_SSL_VERIFYHOST, 0);
547 548
548 curl_easy_setopt(handle->curl, CURLOPT_FOLLOWLOCATION, 1); 549 curl_easy_setopt(handle->curl, CURLOPT_FOLLOWLOCATION, 1);
549 550
551
552 {
553 gboolean tmp = FALSE;
554 ConfigDb *db;
555
556 db = bmp_cfg_db_open();
557
558 bmp_cfg_db_get_bool(db, NULL, "proxy_use", &tmp);
559 if (tmp == TRUE)
560 {
561 gchar *proxy_host = NULL;
562 gint proxy_port = 0;
563
564 bmp_cfg_db_get_string(db, NULL, "proxy_host", &proxy_host);
565 bmp_cfg_db_get_int(db, NULL, "proxy_port", &proxy_port);
566
567 curl_easy_setopt(handle->curl, CURLOPT_PROXY, proxy_host);
568 curl_easy_setopt(handle->curl, CURLOPT_PROXYPORT, proxy_port);
569
570 tmp = FALSE;
571
572 bmp_cfg_db_get_bool(db, NULL, "proxy_use_auth", &tmp);
573 if (tmp == TRUE)
574 {
575 gchar *userbuf, *proxy_user = NULL, *proxy_pass = NULL;
576
577 bmp_cfg_db_get_string(db, NULL, "proxy_user", &proxy_user);
578 bmp_cfg_db_get_string(db, NULL, "proxy_pass", &proxy_pass);
579
580 userbuf = g_strdup_printf("%s:%s",
581 proxy_user != NULL ? proxy_user : "",
582 proxy_pass != NULL ? proxy_pass : "");
583
584 if (proxy_user != NULL)
585 g_free(proxy_user);
586
587 if (proxy_pass != NULL)
588 g_free(proxy_pass);
589
590 curl_easy_setopt(handle->curl, CURLOPT_PROXYUSERPWD, userbuf);
591
592 g_free(userbuf);
593 }
594
595 if (proxy_host != NULL)
596 g_free(proxy_host);
597 }
598 }
599
550 { 600 {
551 struct curl_slist *hdr = NULL; 601 struct curl_slist *hdr = NULL;
552 hdr = curl_slist_append(hdr, "icy-metadata:1"); 602 hdr = curl_slist_append(hdr, "icy-metadata:1");
553 hdr = curl_slist_append(hdr, "User-Agent: Audacious/" VERSION " (curl transport)"); 603 hdr = curl_slist_append(hdr, "User-Agent: Audacious/" VERSION " (curl transport)");
554 curl_easy_setopt(handle->curl, CURLOPT_HTTPHEADER, hdr); 604 curl_easy_setopt(handle->curl, CURLOPT_HTTPHEADER, hdr);