• R/O
  • SSH
  • HTTPS

poi-poi-capsule: Commit


Commit MetaInfo

Révision268 (tree)
l'heure2011-04-20 23:31:26
Auteurpoi-poi-capsule

Message de Log

新規追加

Change Summary

Modification

--- trunk/0.2.X/AsyncConnectionGoogle.h (nonexistent)
+++ trunk/0.2.X/AsyncConnectionGoogle.h (revision 268)
@@ -0,0 +1,32 @@
1+//
2+// AsyncConnectionGoogle.h
3+// GalapagosReader
4+//
5+// Created by Yoshitaka Sakamaki on 11/04/20.
6+// Copyright 2011 __MyCompanyName__. All rights reserved.
7+//
8+// Licensed under the Apache License, Version 2.0 (the "License");
9+// you may not use this file except in compliance with the License.
10+// You may obtain a copy of the License at
11+//
12+// http://www.apache.org/licenses/LICENSE-2.0
13+//
14+// Unless required by applicable law or agreed to in writing, software
15+// distributed under the License is distributed on an "AS IS" BASIS,
16+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+// See the License for the specific language governing permissions and
18+// limitations under the License.
19+
20+#import <Cocoa/Cocoa.h>
21+#import "AsyncConnection.h"
22+
23+@interface AsyncConnectionGoogle : AsyncConnection {
24+
25+}
26+-(BOOL)beginLoadDataFromURL:(NSURL *)theUrl
27+ delegate:(id)theDelegate
28+ didEndSelector:(SEL)endSelector
29+ method:(NSString*)theMethod
30+ body:(NSString*)theBody;
31+
32+@end
--- trunk/0.2.X/AsyncConnectionGoogle.m (nonexistent)
+++ trunk/0.2.X/AsyncConnectionGoogle.m (revision 268)
@@ -0,0 +1,77 @@
1+//
2+// AsyncConnectionGoogle.m
3+// GalapagosReader
4+//
5+// Created by Yoshitaka Sakamaki on 11/04/20.
6+// Copyright 2011 __MyCompanyName__. All rights reserved.
7+//
8+// Licensed under the Apache License, Version 2.0 (the "License");
9+// you may not use this file except in compliance with the License.
10+// You may obtain a copy of the License at
11+//
12+// http://www.apache.org/licenses/LICENSE-2.0
13+//
14+// Unless required by applicable law or agreed to in writing, software
15+// distributed under the License is distributed on an "AS IS" BASIS,
16+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+// See the License for the specific language governing permissions and
18+// limitations under the License.
19+
20+#import "AsyncConnectionGoogle.h"
21+#import "StringExtensions.h"
22+#import "Constants.h"
23+#import "ViennaApp.h"
24+
25+
26+// Private functions
27+@interface AsyncConnectionGoogle (Private)
28+-(void)setURLString:(NSString *)newURLString;
29+@end
30+
31+@implementation AsyncConnectionGoogle
32+
33+-(BOOL)beginLoadDataFromURL:(NSURL *)theUrl
34+ delegate:(id)theDelegate
35+ didEndSelector:(SEL)endSelector
36+ method:(NSString*)theMethod
37+ body:(NSString*)theBody
38+{
39+ delegate = theDelegate;
40+ handler = endSelector;
41+ [self setURLString:[theUrl absoluteString]];
42+
43+ NSMutableURLRequest * theRequest = [NSMutableURLRequest requestWithURL:theUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
44+ if (theRequest == nil)
45+ return NO;
46+
47+ if (httpHeaders != nil)
48+ {
49+ for (NSString * httpFieldName in httpHeaders)
50+ {
51+ NSString * fieldValue = [httpHeaders objectForKey:httpFieldName];
52+ if (fieldValue != nil && ![fieldValue isBlank])
53+ [theRequest addValue:fieldValue forHTTPHeaderField:httpFieldName];
54+ }
55+ }
56+
57+ // Some sites refuse to respond without a User-agent string.
58+ [theRequest addValue:[NSString stringWithFormat:MA_DefaultUserAgentString, [((ViennaApp *)NSApp) applicationVersion]] forHTTPHeaderField:@"User-agent"];
59+
60+ // set method
61+ [theRequest setHTTPMethod:theMethod];
62+
63+ // set body
64+ if (theBody != nil) {
65+ [theRequest setHTTPBody:[theBody dataUsingEncoding:NSUTF8StringEncoding]];
66+ }
67+
68+ status = MA_Connect_Stopped;
69+ isConnectionComplete = NO;
70+
71+ // Changed to not use the [NSURLConnection connectionWithRequest:delegate: and then retain,
72+ // no sense putting it in an autorelease pool if it has no reason to be there
73+ connector = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
74+ return connector != nil;
75+}
76+
77+@end
Afficher sur ancien navigateur de dépôt.