Source file src/vendor/golang.org/x/net/internal/http3/qpack_static.go

     1  // Copyright 2025 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 http3
     6  
     7  import "sync"
     8  
     9  type tableEntry struct {
    10  	name  string
    11  	value string
    12  }
    13  
    14  // staticTableEntry returns the static table entry with the given index.
    15  func staticTableEntry(index int64) (tableEntry, error) {
    16  	if index >= int64(len(staticTableEntries)) {
    17  		return tableEntry{}, errQPACKDecompressionFailed
    18  	}
    19  	return staticTableEntries[index], nil
    20  }
    21  
    22  func initStaticTableMaps() {
    23  	staticTableByName = make(map[string]int)
    24  	staticTableByNameValue = make(map[tableEntry]int)
    25  	for i, ent := range staticTableEntries {
    26  		if _, ok := staticTableByName[ent.name]; !ok {
    27  			staticTableByName[ent.name] = i
    28  		}
    29  		staticTableByNameValue[ent] = i
    30  	}
    31  }
    32  
    33  var (
    34  	staticTableOnce        sync.Once
    35  	staticTableByName      map[string]int
    36  	staticTableByNameValue map[tableEntry]int
    37  )
    38  
    39  // https://www.rfc-editor.org/rfc/rfc9204.html#appendix-A
    40  //
    41  // Note that this is different from the HTTP/2 static table.
    42  var staticTableEntries = [...]tableEntry{
    43  	0:  {":authority", ""},
    44  	1:  {":path", "/"},
    45  	2:  {"age", "0"},
    46  	3:  {"content-disposition", ""},
    47  	4:  {"content-length", "0"},
    48  	5:  {"cookie", ""},
    49  	6:  {"date", ""},
    50  	7:  {"etag", ""},
    51  	8:  {"if-modified-since", ""},
    52  	9:  {"if-none-match", ""},
    53  	10: {"last-modified", ""},
    54  	11: {"link", ""},
    55  	12: {"location", ""},
    56  	13: {"referer", ""},
    57  	14: {"set-cookie", ""},
    58  	15: {":method", "CONNECT"},
    59  	16: {":method", "DELETE"},
    60  	17: {":method", "GET"},
    61  	18: {":method", "HEAD"},
    62  	19: {":method", "OPTIONS"},
    63  	20: {":method", "POST"},
    64  	21: {":method", "PUT"},
    65  	22: {":scheme", "http"},
    66  	23: {":scheme", "https"},
    67  	24: {":status", "103"},
    68  	25: {":status", "200"},
    69  	26: {":status", "304"},
    70  	27: {":status", "404"},
    71  	28: {":status", "503"},
    72  	29: {"accept", "*/*"},
    73  	30: {"accept", "application/dns-message"},
    74  	31: {"accept-encoding", "gzip, deflate, br"},
    75  	32: {"accept-ranges", "bytes"},
    76  	33: {"access-control-allow-headers", "cache-control"},
    77  	34: {"access-control-allow-headers", "content-type"},
    78  	35: {"access-control-allow-origin", "*"},
    79  	36: {"cache-control", "max-age=0"},
    80  	37: {"cache-control", "max-age=2592000"},
    81  	38: {"cache-control", "max-age=604800"},
    82  	39: {"cache-control", "no-cache"},
    83  	40: {"cache-control", "no-store"},
    84  	41: {"cache-control", "public, max-age=31536000"},
    85  	42: {"content-encoding", "br"},
    86  	43: {"content-encoding", "gzip"},
    87  	44: {"content-type", "application/dns-message"},
    88  	45: {"content-type", "application/javascript"},
    89  	46: {"content-type", "application/json"},
    90  	47: {"content-type", "application/x-www-form-urlencoded"},
    91  	48: {"content-type", "image/gif"},
    92  	49: {"content-type", "image/jpeg"},
    93  	50: {"content-type", "image/png"},
    94  	51: {"content-type", "text/css"},
    95  	52: {"content-type", "text/html; charset=utf-8"},
    96  	53: {"content-type", "text/plain"},
    97  	54: {"content-type", "text/plain;charset=utf-8"},
    98  	55: {"range", "bytes=0-"},
    99  	56: {"strict-transport-security", "max-age=31536000"},
   100  	57: {"strict-transport-security", "max-age=31536000; includesubdomains"},
   101  	58: {"strict-transport-security", "max-age=31536000; includesubdomains; preload"},
   102  	59: {"vary", "accept-encoding"},
   103  	60: {"vary", "origin"},
   104  	61: {"x-content-type-options", "nosniff"},
   105  	62: {"x-xss-protection", "1; mode=block"},
   106  	63: {":status", "100"},
   107  	64: {":status", "204"},
   108  	65: {":status", "206"},
   109  	66: {":status", "302"},
   110  	67: {":status", "400"},
   111  	68: {":status", "403"},
   112  	69: {":status", "421"},
   113  	70: {":status", "425"},
   114  	71: {":status", "500"},
   115  	72: {"accept-language", ""},
   116  	73: {"access-control-allow-credentials", "FALSE"},
   117  	74: {"access-control-allow-credentials", "TRUE"},
   118  	75: {"access-control-allow-headers", "*"},
   119  	76: {"access-control-allow-methods", "get"},
   120  	77: {"access-control-allow-methods", "get, post, options"},
   121  	78: {"access-control-allow-methods", "options"},
   122  	79: {"access-control-expose-headers", "content-length"},
   123  	80: {"access-control-request-headers", "content-type"},
   124  	81: {"access-control-request-method", "get"},
   125  	82: {"access-control-request-method", "post"},
   126  	83: {"alt-svc", "clear"},
   127  	84: {"authorization", ""},
   128  	85: {"content-security-policy", "script-src 'none'; object-src 'none'; base-uri 'none'"},
   129  	86: {"early-data", "1"},
   130  	87: {"expect-ct", ""},
   131  	88: {"forwarded", ""},
   132  	89: {"if-range", ""},
   133  	90: {"origin", ""},
   134  	91: {"purpose", "prefetch"},
   135  	92: {"server", ""},
   136  	93: {"timing-allow-origin", "*"},
   137  	94: {"upgrade-insecure-requests", "1"},
   138  	95: {"user-agent", ""},
   139  	96: {"x-forwarded-for", ""},
   140  	97: {"x-frame-options", "deny"},
   141  	98: {"x-frame-options", "sameorigin"},
   142  }
   143  

View as plain text