blob: 75c8800140ffa6bcacfd081afa4ac2722a2ada51 [file] [log] [blame]
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Global constants.
class Const {
// Bytes for "HTTP".
static const HTTP = [72, 84, 84, 80];
// Bytes for "HTTP/1.".
static const HTTP1DOT = [72, 84, 84, 80, 47, 49, 46];
// Bytes for "HTTP/1.0".
static const HTTP10 = [72, 84, 84, 80, 47, 49, 46, 48];
// Bytes for "HTTP/1.1".
static const HTTP11 = [72, 84, 84, 80, 47, 49, 46, 49];
static const bool T = true;
static const bool F = false;
// Lookup-map for the following characters: '()<>@,;:\\"/[]?={} \t'.
static const SEPARATOR_MAP = [
F, F, F, F, F, F, F, F, F, T, F, F, F, F, F, F, F, F, F, F, F, F, F, F, //
F, F, F, F, F, F, F, F, T, F, T, F, F, F, F, F, T, T, F, F, T, F, F, T, //
F, F, F, F, F, F, F, F, F, F, T, T, T, T, T, T, T, F, F, F, F, F, F, F, //
F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, T, T, T, F, F, //
F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, //
F, F, F, T, F, T, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, //
F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, //
F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, //
F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, //
F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, //
F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F
];
}
// Frequently used character codes.
class CharCode {
static const int HT = 9;
static const int LF = 10;
static const int CR = 13;
static const int SP = 32;
static const int AMPERSAND = 38;
static const int COMMA = 44;
static const int DASH = 45;
static const int SLASH = 47;
static const int ZERO = 48;
static const int ONE = 49;
static const int COLON = 58;
static const int SEMI_COLON = 59;
static const int EQUAL = 61;
static bool isTokenChar(int byte) {
return byte > 31 && byte < 128 && !Const.SEPARATOR_MAP[byte];
}
static bool isValueChar(int byte) {
return (byte > 31 && byte < 128) ||
(byte == CharCode.SP) ||
(byte == CharCode.HT);
}
}