OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * HTTP status codes. | 8 * HTTP status codes. |
9 */ | 9 */ |
10 abstract class HttpStatus { | 10 abstract class HttpStatus { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 * | 444 * |
445 * text/plain; q=0.3, text/html | 445 * text/plain; q=0.3, text/html |
446 * | 446 * |
447 * use code like this: | 447 * use code like this: |
448 * | 448 * |
449 * HttpClientRequest request = ...; | 449 * HttpClientRequest request = ...; |
450 * var v = new HeaderValue("text/plain", {"q": "0.3"}); | 450 * var v = new HeaderValue("text/plain", {"q": "0.3"}); |
451 * request.headers.add(HttpHeaders.ACCEPT, v); | 451 * request.headers.add(HttpHeaders.ACCEPT, v); |
452 * request.headers.add(HttpHeaders.ACCEPT, "text/html"); | 452 * request.headers.add(HttpHeaders.ACCEPT, "text/html"); |
453 * | 453 * |
454 * To parse the header values use the [:fromString:] constructor. | 454 * To parse the header values use the [:parse:] static method. |
455 * | 455 * |
456 * HttpRequest request = ...; | 456 * HttpRequest request = ...; |
457 * List<String> values = request.headers[HttpHeaders.ACCEPT]; | 457 * List<String> values = request.headers[HttpHeaders.ACCEPT]; |
458 * values.forEach((value) { | 458 * values.forEach((value) { |
459 * HeaderValue v = new HeaderValue.fromString(value); | 459 * HeaderValue v = HeaderValue.parse(value); |
460 * // Use v.value and v.parameters | 460 * // Use v.value and v.parameters |
461 * }); | 461 * }); |
462 * | 462 * |
463 * An instance of [HeaderValue] is immutable. | 463 * An instance of [HeaderValue] is immutable. |
464 */ | 464 */ |
465 abstract class HeaderValue { | 465 abstract class HeaderValue { |
466 /** | 466 /** |
467 * Creates a new header value object setting the value part. | 467 * Creates a new header value object setting the value part. |
468 */ | 468 */ |
469 factory HeaderValue([String value = "", Map<String, String> parameters]) { | 469 factory HeaderValue([String value = "", Map<String, String> parameters]) { |
470 return new _HeaderValue(value, parameters); | 470 return new _HeaderValue(value, parameters); |
471 } | 471 } |
472 | 472 |
473 /** | 473 /** |
474 * Creates a new header value object from parsing a header value | 474 * Creates a new header value object from parsing a header value |
475 * string with both value and optional parameters. | 475 * string with both value and optional parameters. |
476 */ | 476 */ |
477 factory HeaderValue.fromString(String value, | 477 static HeaderValue parse(String value, |
478 {String parameterSeparator: ";"}) { | 478 {String parameterSeparator: ";"}) { |
479 return new _HeaderValue.fromString( | 479 return _HeaderValue.parse(value, parameterSeparator: parameterSeparator); |
480 value, parameterSeparator: parameterSeparator); | |
481 } | 480 } |
482 | 481 |
483 /** | 482 /** |
484 * Gets the header value. | 483 * Gets the header value. |
485 */ | 484 */ |
486 String get value; | 485 String get value; |
487 | 486 |
488 /** | 487 /** |
489 * Gets the map of parameters. | 488 * Gets the map of parameters. |
490 */ | 489 */ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 * Creates a new content type object from parsing a Content-Type | 544 * Creates a new content type object from parsing a Content-Type |
546 * header value. As primary type, sub type and parameter names and | 545 * header value. As primary type, sub type and parameter names and |
547 * values are not case sensitive all these values will be converted | 546 * values are not case sensitive all these values will be converted |
548 * to lower case. Parsing this string | 547 * to lower case. Parsing this string |
549 * | 548 * |
550 * text/html; charset=utf-8 | 549 * text/html; charset=utf-8 |
551 * | 550 * |
552 * will create a content type object with primary type [:text:], sub | 551 * will create a content type object with primary type [:text:], sub |
553 * type [:html:] and parameter [:charset:] with value [:utf-8:]. | 552 * type [:html:] and parameter [:charset:] with value [:utf-8:]. |
554 */ | 553 */ |
555 factory ContentType.fromString(String value) { | 554 static ContentType parse(String value) { |
556 return new _ContentType.fromString(value); | 555 return _ContentType.parse(value); |
557 } | 556 } |
558 | 557 |
559 /** | 558 /** |
560 * Gets the mime-type, without any parameters. | 559 * Gets the mime-type, without any parameters. |
561 */ | 560 */ |
562 String get mimeType; | 561 String get mimeType; |
563 | 562 |
564 /** | 563 /** |
565 * Gets the primary type. | 564 * Gets the primary type. |
566 */ | 565 */ |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 class RedirectLimitExceededException extends RedirectException { | 1364 class RedirectLimitExceededException extends RedirectException { |
1366 const RedirectLimitExceededException(List<RedirectInfo> redirects) | 1365 const RedirectLimitExceededException(List<RedirectInfo> redirects) |
1367 : super("Redirect limit exceeded", redirects); | 1366 : super("Redirect limit exceeded", redirects); |
1368 } | 1367 } |
1369 | 1368 |
1370 | 1369 |
1371 class RedirectLoopException extends RedirectException { | 1370 class RedirectLoopException extends RedirectException { |
1372 const RedirectLoopException(List<RedirectInfo> redirects) | 1371 const RedirectLoopException(List<RedirectInfo> redirects) |
1373 : super("Redirect loop detected", redirects); | 1372 : super("Redirect loop detected", redirects); |
1374 } | 1373 } |
OLD | NEW |