带阿里标识的版本

This commit is contained in:
robin
2026-02-28 18:55:33 +08:00
parent 150799f41d
commit 5d0b7c7e91
477 changed files with 10813 additions and 4044 deletions

View File

@@ -1,12 +1,12 @@
//
// HttpdnsNWHTTPClient_BasicIntegrationTests.m
// AlicloudHttpDNSTests
// TrustHttpDNSTests
//
// @author Created by Claude Code on 2025-11-01
// Copyright © 2025 alibaba-inc.com. All rights reserved.
// Copyright © 2025 trustapp.com. All rights reserved.
//
// - (G) (J)
// 12 G:7 + J:5
// - (G) <EFBFBD><EFBFBD>?(J) <EFBFBD><EFBFBD>?
// <EFBFBD><EFBFBD>?2 G:7 + J:5<EFBFBD><EFBFBD>?
//
#import "HttpdnsNWHTTPClientTestBase.h"
@@ -134,7 +134,7 @@
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *error = nil;
// httpbin.org/stream-bytes chunked
// httpbin.org/stream-bytes chunked <EFBFBD><EFBFBD>?
HttpdnsNWHTTPClientResponse *response = [self.client performRequestWithURLString:@"http://127.0.0.1:11080/stream-bytes/1024"
userAgent:@"HttpdnsNWHTTPClient/1.0"
timeout:15.0
@@ -145,7 +145,7 @@
XCTAssertEqual(response.statusCode, 200);
XCTAssertEqual(response.body.length, 1024, @"Should receive exactly 1024 bytes");
// Transfer-Encoding
// Transfer-Encoding <EFBFBD><EFBFBD>?
NSString *transferEncoding = response.headers[@"transfer-encoding"];
if (transferEncoding) {
XCTAssertTrue([transferEncoding containsString:@"chunked"], @"Should use chunked encoding");
@@ -157,7 +157,7 @@
[self waitForExpectations:@[expectation] timeout:20.0];
}
#pragma mark -
#pragma mark - <EFBFBD><EFBFBD>?
// G.6
- (void)testIntegration_RequestTimeout_ReturnsError {
@@ -165,7 +165,7 @@
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *error = nil;
// httpbin.org/delay/10 10 2
// httpbin.org/delay/10 <EFBFBD><EFBFBD>?10 2 <EFBFBD><EFBFBD>?
HttpdnsNWHTTPClientResponse *response = [self.client performRequestWithURLString:@"http://127.0.0.1:11080/delay/10"
userAgent:@"HttpdnsNWHTTPClient/1.0"
timeout:2.0
@@ -180,7 +180,7 @@
[self waitForExpectations:@[expectation] timeout:5.0];
}
// G.7
// G.7 <EFBFBD><EFBFBD>?
- (void)testIntegration_CustomHeaders_Reflected {
XCTestExpectation *expectation = [self expectationWithDescription:@"Custom headers"];
@@ -194,7 +194,7 @@
XCTAssertNotNil(response);
XCTAssertEqual(response.statusCode, 200);
// JSON User-Agent
// JSON User-Agent <EFBFBD><EFBFBD>?
NSError *jsonError = nil;
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:response.body
options:0
@@ -212,7 +212,7 @@
#pragma mark - J.
// J.1 31
// J.1 <EFBFBD><EFBFBD>?1
- (void)testConnectionReuse_Expiry31Seconds_NewConnectionCreated {
if (getenv("SKIP_SLOW_TESTS")) {
return;
@@ -252,12 +252,12 @@
[self waitForExpectations:@[expectation] timeout:70.0];
}
// J.2
// J.2 <EFBFBD><EFBFBD>?
- (void)testConnectionReuse_TenRequests_OnlyFourConnectionsKept {
XCTestExpectation *expectation = [self expectationWithDescription:@"Pool size limit"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// 10
// 10<EFBFBD><EFBFBD>?
for (NSInteger i = 0; i < 10; i++) {
NSError *error = nil;
HttpdnsNWHTTPClientResponse *response = [self.client performRequestWithURLString:@"http://127.0.0.1:11080/get"
@@ -267,7 +267,7 @@
XCTAssertTrue(response != nil || error != nil);
}
//
// <EFBFBD><EFBFBD>?
[NSThread sleepForTimeInterval:1.0];
//
@@ -330,7 +330,7 @@
error:&httpError];
XCTAssertTrue(httpResponse != nil || httpError != nil);
// HTTPS 使 key
// HTTPS 使<EFBFBD><EFBFBD>?key<EFBFBD><EFBFBD>?
NSError *httpsError = nil;
HttpdnsNWHTTPClientResponse *httpsResponse = [self.client performRequestWithURLString:@"https://127.0.0.1:11443/get"
userAgent:@"HTTPS"
@@ -345,7 +345,7 @@
[self waitForExpectations:@[expectation] timeout:35.0];
}
// J.5
// J.5 <EFBFBD><EFBFBD>?
- (void)testConnectionReuse_TwentyRequestsOneSecondApart_ConnectionKeptAlive {
if (getenv("SKIP_SLOW_TESTS")) {
return;
@@ -359,7 +359,7 @@
// 201
for (NSInteger i = 0; i < 20; i++) {
// 1
// 1<EFBFBD><EFBFBD>?
if (i > 0) {
[NSThread sleepForTimeInterval:1.0];
}
@@ -381,10 +381,10 @@
}
}
//
// <EFBFBD><EFBFBD>?
XCTAssertGreaterThan(successCount, 15, @"Most requests should succeed with connection reuse");
// 使keep-alive
// 使keep-alive<EFBFBD><EFBFBD>?
if (requestTimes.count >= 10) {
double firstRequestTime = [requestTimes[0] doubleValue];
double laterAvgTime = 0;
@@ -399,7 +399,7 @@
[expectation fulfill];
});
// : 19sleep + 20×~2 = 5950退
// : 19sleep + 20×~2<EFBFBD><EFBFBD>?= 5950退
[self waitForExpectations:@[expectation] timeout:50.0];
}