ObjFW  Check-in [9575887d67]

Overview
Comment:Optimize sending of headers in OFHTTPRequest.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9575887d67edf9266c8d9d8edd1e2893f84f3e8a56f69ee1d121ab126e287ebc
User & Date: js on 2011-04-28 18:44:52
Other Links: manifest | tags
Context
2011-04-30
15:26
Include the complete result in an OFHTTPRequestFailedException. check-in: 5854471001 user: js tags: trunk
2011-04-28
18:44
Optimize sending of headers in OFHTTPRequest. check-in: 9575887d67 user: js tags: trunk
18:15
Nicer description for empty collections. check-in: d01d9805b3 user: js tags: trunk
Changes

Modified src/OFHTTPRequest.m from [4f74296a47] to [8d29aa8502].

206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
		    autorelease];
	}

	@try {
		OFString *line, *path;
		OFMutableDictionary *serverHeaders;
		OFDataArray *data;
		OFEnumerator *enumerator;
		OFString *key;
		int status;
		const char *type = NULL;
		char *buffer;
		size_t bytesReceived;
		OFString *contentLengthHeader;

		[sock connectToHost: [URL host]
			     onPort: [URL port]];

		/*
		 * Work around a bug with packet bisection in lighttpd when
		 * using HTTPS.







|
|




<







206
207
208
209
210
211
212
213
214
215
216
217
218

219
220
221
222
223
224
225
		    autorelease];
	}

	@try {
		OFString *line, *path;
		OFMutableDictionary *serverHeaders;
		OFDataArray *data;
		OFEnumerator *keyEnumerator, *objectEnumerator;
		OFString *key, *object, *contentLengthHeader;
		int status;
		const char *type = NULL;
		char *buffer;
		size_t bytesReceived;


		[sock connectToHost: [URL host]
			     onPort: [URL port]];

		/*
		 * Work around a bug with packet bisection in lighttpd when
		 * using HTTPS.
245
246
247
248
249
250
251
252

253

254
255
256
257
258
259
260
261
262
263

		if ([URL port] == 80)
			[sock writeFormat: @"Host: %@\r\n", [URL host]];
		else
			[sock writeFormat: @"Host: %@:%d\r\n", [URL host],
					   [URL port]];

		enumerator = [headers keyEnumerator];



		while ((key = [enumerator nextObject]) != nil)
			[sock writeFormat: @"%@: %@\r\n",
					   key, [headers objectForKey: key]];

		if (requestType == OF_HTTP_REQUEST_TYPE_POST) {
			if ([headers objectForKey: @"Content-Type"] == nil)
				[sock writeString: @"Content-Type: "
				   @"application/x-www-form-urlencoded\r\n"];

			if ([headers objectForKey: @"Content-Length"] == nil)







|
>

>
|
|
<







244
245
246
247
248
249
250
251
252
253
254
255
256

257
258
259
260
261
262
263

		if ([URL port] == 80)
			[sock writeFormat: @"Host: %@\r\n", [URL host]];
		else
			[sock writeFormat: @"Host: %@:%d\r\n", [URL host],
					   [URL port]];

		keyEnumerator = [headers keyEnumerator];
		objectEnumerator = [headers objectEnumerator];

		while ((key = [keyEnumerator nextObject]) != nil &&
		    (object = [objectEnumerator nextObject]) != nil)
			[sock writeFormat: @"%@: %@\r\n", key, object];


		if (requestType == OF_HTTP_REQUEST_TYPE_POST) {
			if ([headers objectForKey: @"Content-Type"] == nil)
				[sock writeString: @"Content-Type: "
				   @"application/x-www-form-urlencoded\r\n"];

			if ([headers objectForKey: @"Content-Length"] == nil)