| @@ -67,8 +67,26 @@ public: | |||||
| if (! decomposeURL (url, hostName, hostPath, hostPort)) | if (! decomposeURL (url, hostName, hostPath, hostPort)) | ||||
| return false; | return false; | ||||
| struct hostent* const host | |||||
| = gethostbyname ((const char*) hostName.toUTF8()); | |||||
| const struct hostent* host = 0; | |||||
| int port = 0; | |||||
| String proxyName, proxyPath; | |||||
| int proxyPort = 0; | |||||
| String proxyURL (getenv ("http_proxy")); | |||||
| if (proxyURL.startsWithIgnoreCase (T("http://"))) | |||||
| { | |||||
| if (! decomposeURL (proxyURL, proxyName, proxyPath, proxyPort)) | |||||
| return false; | |||||
| host = gethostbyname ((const char*) proxyName.toUTF8()); | |||||
| port = proxyPort; | |||||
| } | |||||
| else | |||||
| { | |||||
| host = gethostbyname ((const char*) hostName.toUTF8()); | |||||
| port = hostPort; | |||||
| } | |||||
| if (host == 0) | if (host == 0) | ||||
| return false; | return false; | ||||
| @@ -98,17 +116,11 @@ public: | |||||
| return false; | return false; | ||||
| } | } | ||||
| String proxyURL (getenv ("http_proxy")); | |||||
| if (! proxyURL.startsWithIgnoreCase (T("http://"))) | |||||
| proxyURL = String::empty; | |||||
| const MemoryBlock requestHeader (createRequestHeader (hostName, hostPath, | |||||
| proxyURL, url, | |||||
| hostPort, | |||||
| const MemoryBlock requestHeader (createRequestHeader (hostName, hostPort, | |||||
| proxyName, proxyPort, | |||||
| hostPath, url, | |||||
| headers, postData, | headers, postData, | ||||
| isPost)); | isPost)); | ||||
| int totalHeaderSent = 0; | int totalHeaderSent = 0; | ||||
| while (totalHeaderSent < requestHeader.getSize()) | while (totalHeaderSent < requestHeader.getSize()) | ||||
| @@ -212,37 +224,26 @@ private: | |||||
| } | } | ||||
| const MemoryBlock createRequestHeader (const String& hostName, | const MemoryBlock createRequestHeader (const String& hostName, | ||||
| const int hostPort, | |||||
| const String& proxyName, | |||||
| const int proxyPort, | |||||
| const String& hostPath, | const String& hostPath, | ||||
| const String& proxyURL, | |||||
| const String& originalURL, | const String& originalURL, | ||||
| const int hostPort, | |||||
| const String& headers, | const String& headers, | ||||
| const MemoryBlock& postData, | const MemoryBlock& postData, | ||||
| const bool isPost) | const bool isPost) | ||||
| { | { | ||||
| String header (isPost ? "POST " : "GET "); | String header (isPost ? "POST " : "GET "); | ||||
| if (proxyURL.isEmpty()) | |||||
| if (proxyName.isEmpty()) | |||||
| { | { | ||||
| header << hostPath << " HTTP/1.0\r\nHost: " | header << hostPath << " HTTP/1.0\r\nHost: " | ||||
| << hostName << ':' << hostPort; | << hostName << ':' << hostPort; | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| String proxyName, proxyPath; | |||||
| int proxyPort; | |||||
| if (! decomposeURL (proxyURL, proxyName, proxyPath, proxyPort)) | |||||
| return MemoryBlock(); | |||||
| header << originalURL << " HTTP/1.0\r\nHost: " | header << originalURL << " HTTP/1.0\r\nHost: " | ||||
| << proxyName << ':' << proxyPort; | << proxyName << ':' << proxyPort; | ||||
| /* xxx needs finishing | |||||
| const char* proxyAuth = getenv ("http_proxy_auth"); | |||||
| if (proxyAuth != 0) | |||||
| header << T("\r\nProxy-Authorization: ") << Base64Encode (proxyAuth); | |||||
| */ | |||||
| } | } | ||||
| header << "\r\nUser-Agent: JUCE/" | header << "\r\nUser-Agent: JUCE/" | ||||