ObjMatrix  Check-in [6b6fe6d802]

Overview
Comment:Adjust to ObjFW changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6b6fe6d802020bb3d3569e43c6a0ca08ca9f7792a5b3499953a7095abe824a19
User & Date: js on 2020-10-31 19:37:57
Other Links: manifest | tags
Context
2021-04-29
00:32
Adjust to ObjFW changes Leaf check-in: e597cc80e1 user: js tags: trunk
2020-10-31
19:37
Adjust to ObjFW changes check-in: 6b6fe6d802 user: js tags: trunk
17:09
Make sync loop automatic check-in: 63d344bd1d user: js tags: trunk
Changes

Modified src/MTXRequest.m from [6c0156e037] to [e2e1bfaf11].

120
121
122
123
124
125
126

127




128
129
130
131

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188

	objc_autoreleasePoolPop(pool);
}

-      (void)client: (OFHTTPClient *)client
  didPerformRequest: (OFHTTPRequest *)request
	   response: (OFHTTPResponse *)response

{




	/* Reset to nil first, so that another one can be performed. */
	mtx_request_block_t block = _block;
	_block = nil;


	@try {
		OFMutableData *responseData = [OFMutableData data];
		while (!response.atEndOfStream) {
			char buffer[512];
			size_t length = [response readIntoBuffer: buffer
							  length: 512];

			[responseData addItems: buffer
					 count: length];
		}

		mtx_response_t responseJSON = [OFString
		    stringWithUTF8String: responseData.items
				  length: responseData.count]
		    .objectByParsingJSON;

		block(responseJSON, response.statusCode, nil);
	} @catch (id e) {
		block(nil, response.statusCode, e);
	}

	[block release];
	[self release];
}

-	  (void)client: (OFHTTPClient *)client
  didFailWithException: (id)exception
	       request: (OFHTTPRequest *)request
{
	/*
	 * Convert OFHTTPRequestFailedException into a response, so that we
	 * still get the JSON for the failed request.
	 */
	if ([exception isKindOfClass: OFHTTPRequestFailedException.class]) {
		[self	       client: client
		    didPerformRequest: request
			     response: [exception response]];
		return;
	}

	/* Reset to nil first, so that another one can be performed. */
	mtx_request_block_t block = _block;
	_block = nil;

	block(nil, 0, exception);

	[block release];
	[self release];
}

-     (void)client: (OFHTTPClient *)client
  wantsRequestBody: (OFStream *)body
	   request: (OFHTTPRequest *)request
{
	[body writeData: _body];
}
@end







>

>
>
>
>




>
|
|
|
|
|
|

|
|
|

|
|
|
|

|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|












120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158























159
160
161
162
163
164
165
166
167
168
169
170
171

	objc_autoreleasePoolPop(pool);
}

-      (void)client: (OFHTTPClient *)client
  didPerformRequest: (OFHTTPRequest *)request
	   response: (OFHTTPResponse *)response
	  exception: (id)exception
{
	if (response != nil &&
	    [exception isKindOfClass: [OFHTTPRequestFailedException class]])
		exception = nil;

	/* Reset to nil first, so that another one can be performed. */
	mtx_request_block_t block = _block;
	_block = nil;

	if (exception == nil) {
		@try {
			OFMutableData *responseData = [OFMutableData data];
			while (!response.atEndOfStream) {
				char buffer[512];
				size_t length = [response readIntoBuffer: buffer
								  length: 512];

				[responseData addItems: buffer
						 count: length];
			}

			mtx_response_t responseJSON = [OFString
			    stringWithUTF8String: responseData.items
					  length: responseData.count]
			    .objectByParsingJSON;

			block(responseJSON, response.statusCode, nil);
		} @catch (id e) {
			block(nil, response.statusCode, e);
		}
	} else























		block(nil, 0, exception);

	[block release];
	[self release];
}

-     (void)client: (OFHTTPClient *)client
  wantsRequestBody: (OFStream *)body
	   request: (OFHTTPRequest *)request
{
	[body writeData: _body];
}
@end