Showing
1 changed file
with
7 additions
and
6 deletions
| @@ -123,18 +123,19 @@ | @@ -123,18 +123,19 @@ | ||
| 123 | 123 | ||
| 124 | - (void)testCharset | 124 | - (void)testCharset |
| 125 | { | 125 | { |
| 126 | + NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/formdata-charset"]; | ||
| 126 | NSString *testString = @"£££s don't seem to buy me many €€€s these days"; | 127 | NSString *testString = @"£££s don't seem to buy me many €€€s these days"; |
| 127 | 128 | ||
| 128 | // Test the default (UTF-8) with a url-encoded request | 129 | // Test the default (UTF-8) with a url-encoded request |
| 129 | NSString *charset = @"utf-8"; | 130 | NSString *charset = @"utf-8"; |
| 130 | - ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/formdata-charset"]]; | 131 | + ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; |
| 131 | [request setPostValue:testString forKey:@"value"]; | 132 | [request setPostValue:testString forKey:@"value"]; |
| 132 | [request start]; | 133 | [request start]; |
| 133 | BOOL success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"Got data in %@: %@",charset,testString]]); | 134 | BOOL success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"Got data in %@: %@",charset,testString]]); |
| 134 | GHAssertTrue(success,@"Failed to correctly encode the data"); | 135 | GHAssertTrue(success,@"Failed to correctly encode the data"); |
| 135 | 136 | ||
| 136 | // Test the default (UTF-8) with a multipart/form-data request | 137 | // Test the default (UTF-8) with a multipart/form-data request |
| 137 | - request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/formdata-charset"]]; | 138 | + request = [ASIFormDataRequest requestWithURL:url]; |
| 138 | [request setPostValue:testString forKey:@"value"]; | 139 | [request setPostValue:testString forKey:@"value"]; |
| 139 | [request setPostFormat:ASIMultipartFormDataPostFormat]; | 140 | [request setPostFormat:ASIMultipartFormDataPostFormat]; |
| 140 | [request start]; | 141 | [request start]; |
| @@ -144,7 +145,7 @@ | @@ -144,7 +145,7 @@ | ||
| 144 | // Test a different charset | 145 | // Test a different charset |
| 145 | testString = @"£££s don't seem to buy me many $$$s these days"; | 146 | testString = @"£££s don't seem to buy me many $$$s these days"; |
| 146 | charset = @"iso-8859-1"; | 147 | charset = @"iso-8859-1"; |
| 147 | - request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/formdata-charset"]]; | 148 | + request = [ASIFormDataRequest requestWithURL:url]; |
| 148 | [request setPostValue:testString forKey:@"value"]; | 149 | [request setPostValue:testString forKey:@"value"]; |
| 149 | [request setStringEncoding:NSISOLatin1StringEncoding]; | 150 | [request setStringEncoding:NSISOLatin1StringEncoding]; |
| 150 | [request start]; | 151 | [request start]; |
| @@ -152,7 +153,7 @@ | @@ -152,7 +153,7 @@ | ||
| 152 | GHAssertTrue(success,@"Failed to correctly encode the data"); | 153 | GHAssertTrue(success,@"Failed to correctly encode the data"); |
| 153 | 154 | ||
| 154 | // And again with multipart/form-data request | 155 | // And again with multipart/form-data request |
| 155 | - request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/formdata-charset"]]; | 156 | + request = [ASIFormDataRequest requestWithURL:url]; |
| 156 | [request setPostValue:testString forKey:@"value"]; | 157 | [request setPostValue:testString forKey:@"value"]; |
| 157 | [request setPostFormat:ASIMultipartFormDataPostFormat]; | 158 | [request setPostFormat:ASIMultipartFormDataPostFormat]; |
| 158 | [request setStringEncoding:NSISOLatin1StringEncoding]; | 159 | [request setStringEncoding:NSISOLatin1StringEncoding]; |
| @@ -162,14 +163,14 @@ | @@ -162,14 +163,14 @@ | ||
| 162 | 163 | ||
| 163 | // Once more for luck | 164 | // Once more for luck |
| 164 | charset = @"windows-1252"; | 165 | charset = @"windows-1252"; |
| 165 | - request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/formdata-charset"]]; | 166 | + request = [ASIFormDataRequest requestWithURL:url]; |
| 166 | [request setPostValue:testString forKey:@"value"]; | 167 | [request setPostValue:testString forKey:@"value"]; |
| 167 | [request setStringEncoding:NSWindowsCP1252StringEncoding]; | 168 | [request setStringEncoding:NSWindowsCP1252StringEncoding]; |
| 168 | [request start]; | 169 | [request start]; |
| 169 | success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"Got data in %@: %@",charset,testString]]); | 170 | success = ([[request responseString] isEqualToString:[NSString stringWithFormat:@"Got data in %@: %@",charset,testString]]); |
| 170 | GHAssertTrue(success,@"Failed to correctly encode the data"); | 171 | GHAssertTrue(success,@"Failed to correctly encode the data"); |
| 171 | 172 | ||
| 172 | - request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/formdata-charset"]]; | 173 | + request = [ASIFormDataRequest requestWithURL:url]; |
| 173 | [request setPostValue:testString forKey:@"value"]; | 174 | [request setPostValue:testString forKey:@"value"]; |
| 174 | [request setPostFormat:ASIMultipartFormDataPostFormat]; | 175 | [request setPostFormat:ASIMultipartFormDataPostFormat]; |
| 175 | [request setStringEncoding:NSWindowsCP1252StringEncoding]; | 176 | [request setStringEncoding:NSWindowsCP1252StringEncoding]; |
-
Please register or login to post a comment