aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/http/header.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2011-11-03 13:26:43 -0700
committerRob Pike <r@golang.org>2011-11-03 13:26:43 -0700
commitde03d502c7e0bd07c6f084ed9b5bb0446df29b49 (patch)
tree4f6d5a7248cfa5419f637393a4bc674aa05ffaf5 /src/pkg/http/header.go
parent5cb4a15320d3b2ac121e3c68249c8ac403120bad (diff)
downloadgo-de03d502c7e0bd07c6f084ed9b5bb0446df29b49.tar.xz
net: renamings
This is Go 1 package renaming CL #3. This one merely moves the source; the import strings will be changed after the next weekly release. This one moves pieces into net. http -> net/http http/cgi -> net/http/cgi http/fcgi -> net/http/fcgi http/pprof -> net/http/pprof http/httptest -> net/http/httptest mail -> net/mail rpc -> net/rpc rpc/jsonrpc -> net/rpc/jsonrpc smtp -> net/smtp url -> net/url Also remove rand (now math/rand) from NOTEST - it has a test. The only edits are in Makefiles and deps.bash. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5335048
Diffstat (limited to 'src/pkg/http/header.go')
-rw-r--r--src/pkg/http/header.go78
1 files changed, 0 insertions, 78 deletions
diff --git a/src/pkg/http/header.go b/src/pkg/http/header.go
deleted file mode 100644
index 6be6016641..0000000000
--- a/src/pkg/http/header.go
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package http
-
-import (
- "fmt"
- "io"
- "net/textproto"
- "sort"
- "strings"
-)
-
-// A Header represents the key-value pairs in an HTTP header.
-type Header map[string][]string
-
-// Add adds the key, value pair to the header.
-// It appends to any existing values associated with key.
-func (h Header) Add(key, value string) {
- textproto.MIMEHeader(h).Add(key, value)
-}
-
-// Set sets the header entries associated with key to
-// the single element value. It replaces any existing
-// values associated with key.
-func (h Header) Set(key, value string) {
- textproto.MIMEHeader(h).Set(key, value)
-}
-
-// Get gets the first value associated with the given key.
-// If there are no values associated with the key, Get returns "".
-// Get is a convenience method. For more complex queries,
-// access the map directly.
-func (h Header) Get(key string) string {
- return textproto.MIMEHeader(h).Get(key)
-}
-
-// Del deletes the values associated with key.
-func (h Header) Del(key string) {
- textproto.MIMEHeader(h).Del(key)
-}
-
-// Write writes a header in wire format.
-func (h Header) Write(w io.Writer) error {
- return h.WriteSubset(w, nil)
-}
-
-var headerNewlineToSpace = strings.NewReplacer("\n", " ", "\r", " ")
-
-// WriteSubset writes a header in wire format.
-// If exclude is not nil, keys where exclude[key] == true are not written.
-func (h Header) WriteSubset(w io.Writer, exclude map[string]bool) error {
- keys := make([]string, 0, len(h))
- for k := range h {
- if exclude == nil || !exclude[k] {
- keys = append(keys, k)
- }
- }
- sort.Strings(keys)
- for _, k := range keys {
- for _, v := range h[k] {
- v = headerNewlineToSpace.Replace(v)
- v = strings.TrimSpace(v)
- if _, err := fmt.Fprintf(w, "%s: %s\r\n", k, v); err != nil {
- return err
- }
- }
- }
- return nil
-}
-
-// CanonicalHeaderKey returns the canonical format of the
-// header key s. The canonicalization converts the first
-// letter and any letter following a hyphen to upper case;
-// the rest are converted to lowercase. For example, the
-// canonical key for "accept-encoding" is "Accept-Encoding".
-func CanonicalHeaderKey(s string) string { return textproto.CanonicalMIMEHeaderKey(s) }