Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Side by Side Diff: runtime/bin/http.dart

Issue 9616004: Add handling of the HTTP header "Host" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/http_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * HTTP status codes. 6 * HTTP status codes.
7 */ 7 */
8 interface HttpStatus { 8 interface HttpStatus {
9 static final int CONTINUE = 100; 9 static final int CONTINUE = 100;
10 static final int SWITCHING_PROTOCOLS = 101; 10 static final int SWITCHING_PROTOCOLS = 101;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 String reasonPhrase; 177 String reasonPhrase;
178 178
179 /** 179 /**
180 * Sets a header on the response. NOTE: If the same header name is 180 * Sets a header on the response. NOTE: If the same header name is
181 * set more than once only the last value will be part of the 181 * set more than once only the last value will be part of the
182 * response. 182 * response.
183 */ 183 */
184 void setHeader(String name, String value); 184 void setHeader(String name, String value);
185 185
186 /** 186 /**
187 * Returns the response headers.
188 */
189 Map<String, String> get headers();
190
191 /**
187 * Returns the output stream for the response. This is used to write 192 * Returns the output stream for the response. This is used to write
188 * the response data. When all response data has been written close 193 * the response data. When all response data has been written close
189 * the stream to indicate the end of the response. 194 * the stream to indicate the end of the response.
190 * 195 *
191 * When this is accessed for the first time the response header is 196 * When this is accessed for the first time the response header is
192 * send. Calling any methods that will change the header after 197 * send. Calling any methods that will change the header after
193 * having retrieved the output stream will throw an exception. 198 * having retrieved the output stream will throw an exception.
194 */ 199 */
195 OutputStream get outputStream(); 200 OutputStream get outputStream();
196 201
197 /** 202 /**
198 * Write string data to the response. The string characters will be 203 * Write string data to the response. The string characters will be
199 * encoded using UFT-8. This is a temporary convenience method as 204 * encoded using UFT-8. This is a temporary convenience method as
200 * long as the OutputStream interface does not have a writeString 205 * long as the OutputStream interface does not have a writeString
201 * method. 206 * method.
202 */ 207 */
203 bool writeString(String string); 208 bool writeString(String string);
204 } 209 }
205 210
206 211
207 /** 212 /**
208 * HTTP client factory. 213 * HTTP client factory.
209 */ 214 */
210 interface HttpClient default _HttpClient { 215 interface HttpClient default _HttpClient {
216 static final int DEFAULT_HTTP_PORT = 80;
217
211 HttpClient(); 218 HttpClient();
212 219
213 /** 220 /**
214 * Opens a HTTP connection. The returned [HttpClientConnection] is 221 * Opens a HTTP connection. The returned [HttpClientConnection] is
215 * used to register handlers for asynchronous events on a Http 222 * used to register callbacks for asynchronous events on the HTTP
216 * connection. 223 * connection. The "Host" header for the request will be set to the
224 * value [host]:[port]. This can be overridden through the
225 * HttpClientRequest interface before the request is sent. NOTE if
226 * [host] is an IP address this will still be set in the "Host"
227 * header.
217 */ 228 */
218 HttpClientConnection open(String method, String host, int port, String path); 229 HttpClientConnection open(String method, String host, int port, String path);
219 230
220 /** 231 /**
221 * Opens a HTTP connection using the GET method. 232 * Opens a HTTP connection using the GET method. See [open] for details.
222 */ 233 */
223 HttpClientConnection get(String host, int port, String path); 234 HttpClientConnection get(String host, int port, String path);
224 235
225 /** 236 /**
226 * Opens a HTTP connection using the POST method. 237 * Opens a HTTP connection using the POST method. See [open] for details.
227 */ 238 */
228 HttpClientConnection post(String host, int port, String path); 239 HttpClientConnection post(String host, int port, String path);
229 240
230 /** 241 /**
231 * Shutdown the HTTP client releasing all resources. 242 * Shutdown the HTTP client releasing all resources.
232 */ 243 */
233 void shutdown(); 244 void shutdown();
234 } 245 }
235 246
236 247
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 * which is also the default. 287 * which is also the default.
277 */ 288 */
278 int contentLength; 289 int contentLength;
279 290
280 /** 291 /**
281 * Gets and sets the keep alive state of the connection. 292 * Gets and sets the keep alive state of the connection.
282 */ 293 */
283 bool keepAlive; 294 bool keepAlive;
284 295
285 /** 296 /**
297 * Gets and sets the " host part of the "Host" header for the
298 * connection. By default this will be set to the value of the host
299 * used when initiating the connection.
300 */
301 String host;
302
303 /**
304 * Gets and sets the port part of the "Host" header for the
305 * connection. By default this will be set to the value of the port
306 * used when initiating the connection.
307 */
308 int port;
309
310 /**
286 * Sets a header on the request. NOTE: If the same header name is 311 * Sets a header on the request. NOTE: If the same header name is
287 * set more than once only the last value set will be part of the 312 * set more than once only the last value set will be part of the
288 * request. 313 * request.
289 */ 314 */
290 void setHeader(String name, String value); 315 void setHeader(String name, String value);
291 316
292 /** 317 /**
318 * Returns the request headers.
319 */
320 Map<String, String> get headers();
321
322 /**
293 * Returns the output stream for the request. This is used to write 323 * Returns the output stream for the request. This is used to write
294 * the request data. When all request data has been written close 324 * the request data. When all request data has been written close
295 * the stream to indicate the end of the request. 325 * the stream to indicate the end of the request.
296 * 326 *
297 * When this is accessed for the first time the request header is 327 * When this is accessed for the first time the request header is
298 * send. Calling any methods that will change the header after 328 * send. Calling any methods that will change the header after
299 * having retrieved the output stream will throw an exception. 329 * having retrieved the output stream will throw an exception.
300 */ 330 */
301 OutputStream get outputStream(); 331 OutputStream get outputStream();
302 332
(...skipping 28 matching lines...) Expand all
331 int get contentLength(); 361 int get contentLength();
332 362
333 /** 363 /**
334 * Returns the keep alive state of the connection. 364 * Returns the keep alive state of the connection.
335 */ 365 */
336 bool get keepAlive(); 366 bool get keepAlive();
337 367
338 /** 368 /**
339 * Returns the response headers. 369 * Returns the response headers.
340 */ 370 */
341 Map get headers(); 371 Map<String, String> get headers();
342 372
343 /** 373 /**
344 * Returns the input stream for the response. This is used to read 374 * Returns the input stream for the response. This is used to read
345 * the response data. 375 * the response data.
346 */ 376 */
347 InputStream get inputStream(); 377 InputStream get inputStream();
348 } 378 }
349 379
350 380
351 class HttpException implements Exception { 381 class HttpException implements Exception {
352 const HttpException([String this.message = ""]); 382 const HttpException([String this.message = ""]);
353 String toString() => "HttpException: $message"; 383 String toString() => "HttpException: $message";
354 final String message; 384 final String message;
355 } 385 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698