ObjMatrix  Diff

Differences From Artifact [bc5bbe8ab6]:

To Artifact [7ace3a8218]:


26
27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49
26
27
28
29
30
31
32

33
34
35
36
37
38
39
40
41

42
43
44
45
46
47
48
49







-
+








-
+







{
	OFData *_body;
	MTXRequestBlock _block;
}

+ (instancetype)requestWithPath: (OFString *)path
		    accessToken: (OFString *)accessToken
		     homeserver: (OFURL *)homeserver
		     homeserver: (OFIRI *)homeserver
{
	return [[[self alloc] initWithPath: path
			       accessToken: accessToken
				homeserver: homeserver] autorelease];
}

- (instancetype)initWithPath: (OFString *)path
		 accessToken: (OFString *)accessToken
		  homeserver: (OFURL *)homeserver
		  homeserver: (OFIRI *)homeserver
{
	self = [super init];

	@try {
		_accessToken = [accessToken copy];
		_homeserver = [homeserver copy];
		_path = [path copy];
87
88
89
90
91
92
93
94

95
96
97
98



99
100
101
102
103
104
105
106
107
108

109
110
111
112
113
114
115
87
88
89
90
91
92
93

94
95



96
97
98
99
100
101
102
103
104
105
106
107

108
109
110
111
112
113
114
115







-
+

-
-
-
+
+
+









-
+








- (void)performWithBlock: (MTXRequestBlock)block
{
	void *pool = objc_autoreleasePoolPush();

	if (_block != nil)
		/* Not the best exception to indicate it's already in-flight. */
		@throw [OFAlreadyConnectedException exception];
		@throw [OFAlreadyOpenException exceptionWithObject: self];

	OFMutableURL *requestURL = [[_homeserver mutableCopy] autorelease];
	requestURL.path = _path;
	requestURL.queryDictionary = _query;
	OFMutableIRI *requestIRI = [[_homeserver mutableCopy] autorelease];
	requestIRI.path = _path;
	requestIRI.queryItems = _queryItems;

	OFMutableDictionary *headers = [OFMutableDictionary dictionary];
	headers[@"User-Agent"] = @"ObjMatrix";
	if (_accessToken != nil)
		headers[@"Authorization"] =
		    [OFString stringWithFormat: @"Bearer %@", _accessToken];
	if (_body != nil)
		headers[@"Content-Length"] = @(_body.count).stringValue;

	OFHTTPRequest *request = [OFHTTPRequest requestWithURL: requestURL];
	OFHTTPRequest *request = [OFHTTPRequest requestWithIRI: requestIRI];
	request.method = _method;
	request.headers = headers;

	OFHTTPClient *client = [OFHTTPClient client];
	client.delegate = self;

	_block = [block copy];