github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/src/pkg/net/http/lex.go (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package http 6 7 // This file deals with lexical matters of HTTP 8 9 var isTokenTable = [127]bool{ 10 '!': true, 11 '#': true, 12 '$': true, 13 '%': true, 14 '&': true, 15 '\'': true, 16 '*': true, 17 '+': true, 18 '-': true, 19 '.': true, 20 '0': true, 21 '1': true, 22 '2': true, 23 '3': true, 24 '4': true, 25 '5': true, 26 '6': true, 27 '7': true, 28 '8': true, 29 '9': true, 30 'A': true, 31 'B': true, 32 'C': true, 33 'D': true, 34 'E': true, 35 'F': true, 36 'G': true, 37 'H': true, 38 'I': true, 39 'J': true, 40 'K': true, 41 'L': true, 42 'M': true, 43 'N': true, 44 'O': true, 45 'P': true, 46 'Q': true, 47 'R': true, 48 'S': true, 49 'T': true, 50 'U': true, 51 'W': true, 52 'V': true, 53 'X': true, 54 'Y': true, 55 'Z': true, 56 '^': true, 57 '_': true, 58 '`': true, 59 'a': true, 60 'b': true, 61 'c': true, 62 'd': true, 63 'e': true, 64 'f': true, 65 'g': true, 66 'h': true, 67 'i': true, 68 'j': true, 69 'k': true, 70 'l': true, 71 'm': true, 72 'n': true, 73 'o': true, 74 'p': true, 75 'q': true, 76 'r': true, 77 's': true, 78 't': true, 79 'u': true, 80 'v': true, 81 'w': true, 82 'x': true, 83 'y': true, 84 'z': true, 85 '|': true, 86 '~': true, 87 } 88 89 func isToken(r rune) bool { 90 i := int(r) 91 return i < len(isTokenTable) && isTokenTable[i] 92 } 93 94 func isNotToken(r rune) bool { 95 return !isToken(r) 96 }