diff options
author | Jay Freeman <saurik@saurik.com> | 2008-04-26 18:01:08 +0000 |
---|---|---|
committer | Jay Freeman <saurik@saurik.com> | 2008-04-26 18:01:08 +0000 |
commit | 2f0aec18a7228129315033351fd5cce7ccc4f772 (patch) | |
tree | 7dc09c522b7ee31c6c43930239b4094f96cfe794 /data/apt/cfnetwork.diff | |
parent | c90567b9bdf08ed9d5bcaa9cf57a8d981fa5e4a0 (diff) |
Fixed the DNS blocking problem on APT.
git-svn-id: http://svn.telesphoreo.org/trunk@247 514c082c-b64e-11dc-b46d-3d985efe055d
Diffstat (limited to 'data/apt/cfnetwork.diff')
-rw-r--r-- | data/apt/cfnetwork.diff | 92 |
1 files changed, 49 insertions, 43 deletions
diff --git a/data/apt/cfnetwork.diff b/data/apt/cfnetwork.diff index 6fbec5cf4..8d8735e33 100644 --- a/data/apt/cfnetwork.diff +++ b/data/apt/cfnetwork.diff @@ -1,6 +1,6 @@ diff -ru apt-0.6.46.4.1/methods/http.cc apt-0.6.46.4.1+iPhone/methods/http.cc --- apt-0.6.46.4.1/methods/http.cc 2006-12-04 14:37:36.000000000 +0000 -+++ apt-0.6.46.4.1+iPhone/methods/http.cc 2008-04-23 11:36:59.000000000 +0000 ++++ apt-0.6.46.4.1+iPhone/methods/http.cc 2008-04-25 09:29:12.000000000 +0000 @@ -30,6 +34,7 @@ #include <apt-pkg/error.h> #include <apt-pkg/hashes.h> @@ -72,7 +72,7 @@ diff -ru apt-0.6.46.4.1/methods/http.cc apt-0.6.46.4.1+iPhone/methods/http.cc string HttpMethod::FailFile; int HttpMethod::FailFd = -1; time_t HttpMethod::FailTime = 0; -@@ -1062,159 +1116,259 @@ +@@ -1062,159 +1116,263 @@ if (Queue == 0) continue; @@ -82,20 +82,7 @@ diff -ru apt-0.6.46.4.1/methods/http.cc apt-0.6.46.4.1+iPhone/methods/http.cc - { - delete Server; - Server = new ServerState(Queue->Uri,this); -+ -+ CFStringEncoding se = kCFStringEncodingUTF8; -+ -+ char *url = strdup(Queue->Uri.c_str()); -+ url: -+ URI uri = std::string(url); -+ std::string hs = uri.Host; -+ -+ struct hostent *he = gethostbyname(hs.c_str()); -+ if (he == NULL || he->h_addr_list[0] == NULL) { -+ _error->Error(hstrerror(h_errno)); -+ Fail(true); -+ free(url); - } +- } - - /* If the server has explicitly said this is the last connection - then we pre-emptively shut down the pipeline and tear down @@ -116,31 +103,7 @@ diff -ru apt-0.6.46.4.1/methods/http.cc apt-0.6.46.4.1+iPhone/methods/http.cc - delete Server; - Server = 0; - continue; -+ -+ uri.Host = inet_ntoa(* (struct in_addr *) he->h_addr_list[0]); -+ -+ std::string urs = uri; -+ -+ CFStringRef sr = CFStringCreateWithCString(kCFAllocatorDefault, urs.c_str(), se); -+ CFURLRef ur = CFURLCreateWithString(kCFAllocatorDefault, sr, NULL); -+ CFRelease(sr); -+ CFHTTPMessageRef hm = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), ur, kCFHTTPVersion1_1); -+ CFRelease(ur); -+ -+ struct stat SBuf; -+ if (stat(Queue->DestFile.c_str(), &SBuf) >= 0 && SBuf.st_size > 0) { -+ sr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("bytes=%li-"), (long) SBuf.st_size - 1); -+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("Range"), sr); -+ CFRelease(sr); -+ -+ sr = CFStringCreateWithCString(kCFAllocatorDefault, TimeRFC1123(SBuf.st_mtime).c_str(), se); -+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("If-Range"), sr); -+ CFRelease(sr); -+ } else if (Queue->LastModified != 0) { -+ sr = CFStringCreateWithCString(kCFAllocatorDefault, TimeRFC1123(SBuf.st_mtime).c_str(), se); -+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("If-Modified-Since"), sr); -+ CFRelease(sr); - } +- } - // Fill the pipeline. - Fetch(0); @@ -179,6 +142,47 @@ diff -ru apt-0.6.46.4.1/methods/http.cc apt-0.6.46.4.1+iPhone/methods/http.cc - continue; - } - }; ++ CFStringEncoding se = kCFStringEncodingUTF8; ++ ++ char *url = strdup(Queue->Uri.c_str()); ++ url: ++ URI uri = std::string(url); ++ std::string hs = uri.Host; ++ ++#if __ENVIRONMENT_ASPEN_VERSION_MIN_REQUIRED__ >= 10200 ++ struct hostent *he = gethostbyname(hs.c_str()); ++ if (he == NULL || he->h_addr_list[0] == NULL) { ++ _error->Error(hstrerror(h_errno)); ++ Fail(true); ++ free(url); ++ } ++ ++ uri.Host = inet_ntoa(* (struct in_addr *) he->h_addr_list[0]); ++#endif ++ ++ std::string urs = uri; ++ ++ CFStringRef sr = CFStringCreateWithCString(kCFAllocatorDefault, urs.c_str(), se); ++ CFURLRef ur = CFURLCreateWithString(kCFAllocatorDefault, sr, NULL); ++ CFRelease(sr); ++ CFHTTPMessageRef hm = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), ur, kCFHTTPVersion1_1); ++ CFRelease(ur); ++ ++ struct stat SBuf; ++ if (stat(Queue->DestFile.c_str(), &SBuf) >= 0 && SBuf.st_size > 0) { ++ sr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("bytes=%li-"), (long) SBuf.st_size - 1); ++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("Range"), sr); ++ CFRelease(sr); ++ ++ sr = CFStringCreateWithCString(kCFAllocatorDefault, TimeRFC1123(SBuf.st_mtime).c_str(), se); ++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("If-Range"), sr); ++ CFRelease(sr); ++ } else if (Queue->LastModified != 0) { ++ sr = CFStringCreateWithCString(kCFAllocatorDefault, TimeRFC1123(SBuf.st_mtime).c_str(), se); ++ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("If-Modified-Since"), sr); ++ CFRelease(sr); ++ } ++ + sr = CFStringCreateWithCString(kCFAllocatorDefault, Machine_, se); + CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Machine"), sr); + CFRelease(sr); @@ -189,9 +193,11 @@ diff -ru apt-0.6.46.4.1/methods/http.cc apt-0.6.46.4.1+iPhone/methods/http.cc + + CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("User-Agent"), CFSTR("Telesphoreo APT-HTTP/1.0.98")); + ++#if __ENVIRONMENT_ASPEN_VERSION_MIN_REQUIRED__ >= 10200 + sr = CFStringCreateWithCString(kCFAllocatorDefault, hs.c_str(), se); + CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("Host"), sr); + CFRelease(sr); ++#endif + + CFReadStreamRef rs = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, hm); + CFRelease(hm); @@ -469,7 +475,7 @@ diff -ru apt-0.6.46.4.1/methods/http.cc apt-0.6.46.4.1+iPhone/methods/http.cc FailCounter = 0; } -@@ -1224,6 +1378,22 @@ +@@ -1224,6 +1382,22 @@ setlocale(LC_ALL, ""); HttpMethod Mth; @@ -494,7 +500,7 @@ diff -ru apt-0.6.46.4.1/methods/http.cc apt-0.6.46.4.1+iPhone/methods/http.cc } diff -ru apt-0.6.46.4.1/methods/makefile apt-0.6.46.4.1+iPhone/methods/makefile --- apt-0.6.46.4.1/methods/makefile 2006-12-04 14:37:36.000000000 +0000 -+++ apt-0.6.46.4.1+iPhone/methods/makefile 2008-04-22 04:03:43.000000000 +0000 ++++ apt-0.6.46.4.1+iPhone/methods/makefile 2008-04-23 11:40:38.000000000 +0000 @@ -47,7 +47,7 @@ # The http method |