Changeset 49752 in webkit


Ignore:
Timestamp:
Oct 18, 2009 10:02:58 AM (15 years ago)
Author:
kevino@webkit.org
Message:

Reviewed by Kevin Ollivier.

Add the ability to specify a proxy for wxWebKit.

https://bugs.webkit.org/show_bug.cgi?id=30446

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r49751 r49752  
     12009-09-13  Kevin Watters  <kevinwatters@gmail.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Add support for proxies in CURL.
     6 
     7        https://bugs.webkit.org/show_bug.cgi?id=30446
     8
     9        * platform/network/curl/ResourceHandleManager.cpp:
     10        (WebCore::ResourceHandleManager::setProxyInfo):
     11        (WebCore::ResourceHandleManager::initializeHandle):
     12        * platform/network/curl/ResourceHandleManager.h:
     13        (WebCore::ResourceHandleManager::):
     14
    1152009-10-18  Joanmarie Diggs  <joanmarie.diggs@gmail.com>
    216
  • trunk/WebCore/platform/network/curl/ResourceHandleManager.cpp

    r49577 r49752  
    410410}
    411411
     412void ResourceHandleManager::setProxyInfo(const String& host,
     413                                         unsigned long port,
     414                                         ProxyType type,
     415                                         const String& username,
     416                                         const String& password)
     417{
     418    m_proxyType = type;
     419
     420    if (!host.length()) {
     421        m_proxy = String("");
     422    } else {
     423        String userPass;
     424        if (username.length() || password.length())
     425            userPass = username + ":" + password + "@";
     426
     427        m_proxy = String("http://") + userPass + host + ":" + String::number(port);
     428    }
     429}
     430
    412431void ResourceHandleManager::removeFromCurl(ResourceHandle* job)
    413432{
     
    754773        d->m_customHeaders = headers;
    755774    }
     775    // curl CURLOPT_USERPWD expects username:password
     776    if (d->m_user.length() || d->m_pass.length()) {
     777        String userpass = d->m_user + ":" + d->m_pass;
     778        curl_easy_setopt(d->m_handle, CURLOPT_USERPWD, userpass.utf8().data());
     779    }
     780
     781    // Set proxy options if we have them.
     782    if (m_proxy.length()) {
     783        curl_easy_setopt(d->m_handle, CURLOPT_PROXY, m_proxy.utf8().data());
     784        curl_easy_setopt(d->m_handle, CURLOPT_PROXYTYPE, m_proxyType);
     785    }
    756786}
    757787
  • trunk/WebCore/platform/network/curl/ResourceHandleManager.h

    r47071 r49752  
    2929#define ResourceHandleManager_h
    3030
     31#include "CString.h"
    3132#include "Frame.h"
    32 #include "CString.h"
     33#include "String.h"
    3334#include "Timer.h"
    3435#include "ResourceHandleClient.h"
     
    4647class ResourceHandleManager {
    4748public:
     49    enum ProxyType {
     50        HTTP = CURLPROXY_HTTP,
     51        Socks4 = CURLPROXY_SOCKS4,
     52        Socks4A = CURLPROXY_SOCKS4A,
     53        Socks5 = CURLPROXY_SOCKS5,
     54        Socks5Hostname = CURLPROXY_SOCKS5_HOSTNAME
     55    };
    4856    static ResourceHandleManager* sharedInstance();
    4957    void add(ResourceHandle*);
     
    5563    void setupPOST(ResourceHandle*, struct curl_slist**);
    5664    void setupPUT(ResourceHandle*, struct curl_slist**);
     65
     66    void setProxyInfo(const String& host = "",
     67                      unsigned long port = 0,
     68                      ProxyType type = HTTP,
     69                      const String& username = "",
     70                      const String& password = "");
    5771
    5872private:
     
    7589    const CString m_certificatePath;
    7690    int m_runningJobs;
     91   
     92    String m_proxy;
     93    ProxyType m_proxyType;
    7794};
    7895
  • trunk/WebKit/wx/ChangeLog

    r49750 r49752  
    1 2009-10-16  Kevin Watters  <kevinwatters@gmail.com>
     12009-10-18  Kevin Watters  <kevinwatters@gmail.com>
     2
     3        Reviewed by Kevin Ollivier.
     4
     5        Add the ability to specify a proxy for wxWebKit.
     6       
     7        https://bugs.webkit.org/show_bug.cgi?id=30446
     8
     9        * WebView.cpp:
     10        (curlProxyType):
     11        (wxWebView::SetProxyInfo):
     12        * WebView.h:
     13
     142009-10-18  Kevin Watters  <kevinwatters@gmail.com>
    215
    316        Reviewed by Kevin Ollivier.
  • trunk/WebKit/wx/WebView.cpp

    r49750 r49752  
    5151#include "RenderObject.h"
    5252#include "RenderView.h"
     53#include "ResourceHandleManager.h"
    5354#include "Scrollbar.h"
    5455#include "SelectionController.h"
     
    925926#endif
    926927}
     928
     929static WebCore::ResourceHandleManager::ProxyType curlProxyType(wxProxyType type)
     930{
     931    switch (type) {
     932        case HTTP: return WebCore::ResourceHandleManager::HTTP;
     933        case Socks4: return WebCore::ResourceHandleManager::Socks4;
     934        case Socks4A: return WebCore::ResourceHandleManager::Socks4A;
     935        case Socks5: return WebCore::ResourceHandleManager::Socks5;
     936        case Socks5Hostname: return WebCore::ResourceHandleManager::Socks5Hostname;
     937        default:
     938            ASSERT_NOT_REACHED();
     939            return WebCore::ResourceHandleManager::HTTP;
     940    }
     941}
     942
     943/* static */
     944void wxWebView::SetProxyInfo(const wxString& host,
     945                             unsigned long port,
     946                             wxProxyType type,
     947                             const wxString& username,
     948                             const wxString& password)
     949{
     950    using WebCore::ResourceHandleManager;
     951    if (ResourceHandleManager* mgr = ResourceHandleManager::sharedInstance())
     952        mgr->setProxyInfo(host, port, curlProxyType(type), username, password);
     953}
  • trunk/WebKit/wx/WebView.h

    r49750 r49752  
    106106};
    107107
     108enum wxProxyType {
     109    HTTP,
     110    Socks4,
     111    Socks4A,
     112    Socks5,
     113    Socks5Hostname
     114};
     115
    108116class WXDLLIMPEXP_WEBKIT wxWebView : public wxWindow
    109117{
     
    200208    static void SetDatabaseDirectory(const wxString& databaseDirectory);
    201209    static wxString GetDatabaseDirectory();
     210
     211    static void SetProxyInfo(const wxString& host = wxEmptyString,
     212                             unsigned long port = 0,
     213                             wxProxyType type = HTTP,
     214                             const wxString& username = wxEmptyString,
     215                             const wxString& password = wxEmptyString);
    202216
    203217protected:
Note: See TracChangeset for help on using the changeset viewer.