本文整理匯總了Golang中http.Header.Set方法的典型用法代碼示例。如果您正苦於以下問題:Golang Header.Set方法的具體用法?Golang Header.Set怎麽用?Golang Header.Set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類http.Header
的用法示例。
在下文中一共展示了Header.Set方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getMultiItemRequest
// for hdrs, only include headers listed as optional from 'http://wiki.basho.com/HTTP-Fetch-Object.html'
func getMultiItemRequest(c Client, bucket, key string, hdrs http.Header, parms http.Values) (req *http.Request) {
if hdrs == nil {
hdrs = http.Header{}
}
if hdrs.Get("Accept") == "" {
hdrs.Set("Accept", "multipart/mixed")
}
req = c.request("GET", c.keyPath(bucket, key), hdrs, parms)
return
}
示例2: readFcgiParams
//read the fcgi parameters contained in data, and store them in storage
func readFcgiParams(data []byte, storage http.Header) {
for idx := 0; len(data) > idx; {
keySize, shift := readFcgiParamSize(data, idx)
idx += shift
valSize, shift := readFcgiParamSize(data, idx)
idx += shift
key := data[idx : idx+keySize]
idx += keySize
val := data[idx : idx+valSize]
idx += valSize
storage.Set(string(key), string(val))
}
}
示例3: setBucketRequest
func setBucketRequest(c Client, name string, props Properties) (req *http.Request, err os.Error) {
hdrs := http.Header{}
hdrs.Set("Content-Type", "application/json")
req = c.request("PUT", c.bucketPath(name), hdrs, nil)
ob, err := json.Marshal(map[string]interface{}{"props": props})
if err == nil {
req.ContentLength = int64(len(ob))
req.Body = ioutil.NopCloser(bytes.NewBuffer(ob))
}
return
}
示例4: OutputJSONObject
func OutputJSONObject(writer io.Writer, obj jsonhelper.JSONObject, lastModified *time.Time, etag string, statusCode int, headers http.Header) (int, http.Header, os.Error) {
if statusCode == 0 {
statusCode = 200
}
if headers == nil {
headers = make(http.Header)
}
//headers.Set("Content-Type", wm.MIME_TYPE_JSON)
if lastModified != nil {
headers.Set("Last-Modified", lastModified.Format(http.TimeFormat))
}
if len(etag) > 0 {
headers.Set("ETag", etag)
}
m := jsonhelper.NewJSONObject()
w := json.NewEncoder(writer)
m.Set("status", "success")
m.Set("result", obj)
w.Encode(m)
return statusCode, headers, nil
}