ObjFW  Check-in [73c723bf39]

Overview
Comment:OFHTTPRequest: Work around a bug in lighttpd with HTTPS.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 73c723bf392e4bd44d7f6602ae7e21b294e33d1d1226d1a2279cbfe76af01aa9
User & Date: js on 2011-02-25 12:02:38
Other Links: manifest | tags
Context
2011-02-25
12:14
OFHTTPRequest: Check Content-Length if present to check for truncation. check-in: 9e647a2ddd user: js tags: trunk
12:02
OFHTTPRequest: Work around a bug in lighttpd with HTTPS. check-in: 73c723bf39 user: js tags: trunk
2011-02-24
18:27
Make it possible to specify a TLS socket class for OFHTTPRequest. check-in: c64d88f50f user: js tags: trunk
Changes

Modified src/OFHTTPRequest.m from [5c79012c43] to [af54b95e34].

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
			    newWithClass: isa
				     URL: URL];

		sock = [[[of_http_request_tls_socket_class alloc] init]
		    autorelease];
	}

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

	@try {
		OFString *line;
		OFMutableDictionary *s_headers;
		OFDataArray *data;
		OFEnumerator *enumerator;
		OFString *key;
		int status;
		const char *t;










		if (requestType == OF_HTTP_REQUEST_TYPE_GET)
			t = "GET";
		if (requestType == OF_HTTP_REQUEST_TYPE_HEAD)
			t = "HEAD";
		if (requestType == OF_HTTP_REQUEST_TYPE_POST)
			t = "POST";







<
<
<








>
>
>
>
>
>
>
>
>







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
			    newWithClass: isa
				     URL: URL];

		sock = [[[of_http_request_tls_socket_class alloc] init]
		    autorelease];
	}




	@try {
		OFString *line;
		OFMutableDictionary *s_headers;
		OFDataArray *data;
		OFEnumerator *enumerator;
		OFString *key;
		int status;
		const char *t;

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

		/*
		 * Work around a bug with packet bisection in lighttpd when
		 * using HTTPS.
		 */
		[sock setBuffersWrites: YES];

		if (requestType == OF_HTTP_REQUEST_TYPE_GET)
			t = "GET";
		if (requestType == OF_HTTP_REQUEST_TYPE_HEAD)
			t = "HEAD";
		if (requestType == OF_HTTP_REQUEST_TYPE_POST)
			t = "POST";
175
176
177
178
179
180
181




182
183
184
185
186
187
188

			if ([headers objectForKey: @"Content-Length"] == nil)
				[sock writeFormat: @"Content-Length: %d\r\n",
				    [queryString cStringLength]];
		}

		[sock writeString: @"\r\n"];





		if (requestType == OF_HTTP_REQUEST_TYPE_POST)
			[sock writeString: queryString];

		/*
		 * We also need to check for HTTP/1.1 since Apache always
		 * declares the reply to be HTTP/1.1.







>
>
>
>







181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198

			if ([headers objectForKey: @"Content-Length"] == nil)
				[sock writeFormat: @"Content-Length: %d\r\n",
				    [queryString cStringLength]];
		}

		[sock writeString: @"\r\n"];

		/* Work around a bug in lighttpd, see above */
		[sock flushWriteBuffer];
		[sock setBuffersWrites: NO];

		if (requestType == OF_HTTP_REQUEST_TYPE_POST)
			[sock writeString: queryString];

		/*
		 * We also need to check for HTTP/1.1 since Apache always
		 * declares the reply to be HTTP/1.1.