示例#1
0
文件: client.go 项目: abneptis/riak
// 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
0
文件: fcgi.go 项目: noppanit/web.go
//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
0
文件: client.go 项目: abneptis/riak
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
0
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
}