This repository has been archived by the owner on Jun 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MGTwitterHTTPURLConnection.m
99 lines (66 loc) · 1.59 KB
/
MGTwitterHTTPURLConnection.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//
// MGTwitterHTTPURLConnection.m
// MGTwitterEngine
//
// Created by Matt Gemmell on 16/02/2008.
// Copyright 2008 Instinctive Code.
//
#import "MGTwitterHTTPURLConnection.h"
#import "NSString+UUID.h"
@implementation MGTwitterHTTPURLConnection
#pragma mark Initializer
- (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate
requestType:(MGTwitterRequestType)requestType responseType:(MGTwitterResponseType)responseType
{
if (self = [super initWithRequest:request delegate:delegate]) {
_data = [[NSMutableData alloc] initWithCapacity:0];
_identifier = [[NSString stringWithNewUUID] retain];
_requestType = requestType;
_responseType = responseType;
_URL = [[request URL] retain];
}
return self;
}
- (void)dealloc
{
[_data release];
[_identifier release];
[_URL release];
[super dealloc];
}
#pragma mark Data helper methods
- (void)resetDataLength
{
[_data setLength:0];
}
- (void)appendData:(NSData *)data
{
[_data appendData:data];
}
#pragma mark Accessors
- (NSString *)identifier
{
return [[_identifier retain] autorelease];
}
- (NSData *)data
{
return [[_data retain] autorelease];
}
- (NSURL *)URL
{
return [[_URL retain] autorelease];
}
- (MGTwitterRequestType)requestType
{
return _requestType;
}
- (MGTwitterResponseType)responseType
{
return _responseType;
}
- (NSString *)description
{
NSString *description = [super description];
return [description stringByAppendingFormat:@" (requestType = %d, identifier = %@)", _requestType, _identifier];
}
@end