Example #1
0
// fetches SC3ML and turns it into a protobuf.
func quakeTechnicalProto(r *http.Request, h http.Header, b *bytes.Buffer) *weft.Result {
	if res := weft.CheckQuery(r, []string{}, []string{}); !res.Ok {
		return res
	}

	by, res := getBytes(s3+strings.TrimPrefix(r.URL.Path, "/quake/technical/")+".xml", "")
	if !res.Ok {
		return res
	}

	q, err := sc3ml.QuakeTechnical(by)
	if err != nil {
		return weft.ServiceUnavailableError(err)
	}

	m, err := proto.Marshal(&q)
	if err != nil {
		return weft.ServiceUnavailableError(err)
	}

	b.Write(m)

	h.Set("Content-Type", protobuf)
	return &weft.StatusOK
}
Example #2
0
func TestWarning(t *testing.T) {
	hdr := http.Header{}
	err := fmt.Errorf("modifier error")

	Warning(hdr, err)

	if got, want := len(hdr["Warning"]), 1; got != want {
		t.Fatalf("len(hdr[%q]): got %d, want %d", "Warning", got, want)
	}

	want := `199 "martian" "modifier error"`
	if got := hdr["Warning"][0]; !strings.HasPrefix(got, want) {
		t.Errorf("hdr[%q][0]: got %q, want to have prefix %q", "Warning", got, want)
	}

	hdr.Set("Date", "Mon, 02 Jan 2006 15:04:05 GMT")
	Warning(hdr, err)

	if got, want := len(hdr["Warning"]), 2; got != want {
		t.Fatalf("len(hdr[%q]): got %d, want %d", "Warning", got, want)
	}

	want = `199 "martian" "modifier error" "Mon, 02 Jan 2006 15:04:05 GMT"`
	if got := hdr["Warning"][1]; got != want {
		t.Errorf("hdr[%q][1]: got %q, want %q", "Warning", got, want)
	}
}
Example #3
0
func (s *Transport) createSubStream(parentID uint64) (*stream, error) {
	referenceID := atomic.AddUint64(&s.referenceCounter, 1)
	headers := http.Header{}
	headers.Set("libchan-ref", strconv.FormatUint(referenceID, 10))
	if parentID > 0 {
		headers.Set("libchan-parent-ref", strconv.FormatUint(parentID, 10))
	}

	providedStream, err := s.provider.NewStream(headers)
	if err != nil {
		return nil, err
	}

	newStream := &stream{
		referenceID: referenceID,
		parentID:    parentID,
		stream:      providedStream,
		session:     s,
	}

	// TODO: hold reference to the newly created stream
	// for possible cleanup. This stream should not be put
	// in the streams maps which holds remotely created
	// streams and will can have reference id conflicts.

	return newStream, nil

}
Example #4
0
func (s *S) TestRespMustRevalidate(c *C) {
	respHeaders := http.Header{}
	respHeaders.Set("Cache-Control", "must-revalidate")
	reqHeaders := http.Header{}

	c.Assert(getFreshness(respHeaders, reqHeaders), Equals, stale)
}
Example #5
0
// Retrieve the list of bytes already transferred by an unfinished upload
func (c *Client) GetUploadBytesSize(fileId, uploadId string, etags []string) (int, error) {
	route := strings.Join([]string{FILE_ROUTE, fileId, "content"}, "/")
	link := c.getURL(route, "")
	newHeader := http.Header{}
	newHeader.Set("Content-Range", "bytes /*/")
	newHeader.Set("Upload-ID", uploadId)
	newHeader.Set("Content-Length", "0")
	if len(etags) > 0 {
		for _, v := range etags {
			newHeader.Add("If-Match", v)
		}
	}

	res, err := c.request("PUT", link, &newHeader, nil)
	defer res.Body.Close()
	if err != nil {
		return 0, nil
	}

	bytesUploaded, err := strconv.Atoi(res.Header.Get("Range"))
	if err != nil {
		return 0, errors.New("Unable to parse value of bytes transferred from HTTP-Header")
	}
	return bytesUploaded, err
}
Example #6
0
func populateViaHeader(header http.Header, httpVersion string) {
	via := httpVersion + " router"
	if prior, ok := header["Via"]; ok {
		via = strings.Join(prior, ", ") + ", " + via
	}
	header.Set("Via", via)
}
Example #7
0
func fakeClientWith(testName string, t *testing.T, data map[string]string) ClientMapper {
	return ClientMapperFunc(func(*meta.RESTMapping) (RESTClient, error) {
		return &fake.RESTClient{
			Codec: testapi.Default.Codec(),
			Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
				p := req.URL.Path
				q := req.URL.RawQuery
				if len(q) != 0 {
					p = p + "?" + q
				}
				body, ok := data[p]
				if !ok {
					t.Fatalf("%s: unexpected request: %s (%s)\n%#v", testName, p, req.URL, req)
				}
				header := http.Header{}
				header.Set("Content-Type", runtime.ContentTypeJSON)
				return &http.Response{
					StatusCode: http.StatusOK,
					Header:     header,
					Body:       stringBody(body),
				}, nil
			}),
		}, nil
	})
}
Example #8
0
func TestJWTAuthenticationWrongToken(t *testing.T) {
	m := minion.Classic(minion.Options{JWTToken: "123"})

	usersHandler := func(ctx *minion.Context) {
		j := struct {
			Message string `json:"message"`
		}{
			"ok",
		}
		ctx.JSON(200, j)
	}

	m.Get("/users", usersHandler)

	ts := httptest.NewServer(m)
	defer ts.Close()

	var j, body string
	var status int

	tokenAuth := jwtauth.New("HS256", []byte("wrong"), nil)
	_, tokenString, _ := tokenAuth.Encode(nil)

	h := http.Header{}
	h.Set("Authorization", "BEARER "+tokenString)

	status, body = tst.Request(t, ts, "GET", "/users", h, nil)
	tst.AssertEqual(t, 401, status)

	j = `{"status":401,"message":"Unauthorized"}`
	tst.AssertEqual(t, j, body)
}
Example #9
0
func createFakeInfo(name string, labels map[string]string) *resource.Info {
	pod := createFakePod(name, labels)
	marshaledObj, _ := json.Marshal(pod)

	mapping := &meta.RESTMapping{
		Resource: name,
		Scope:    meta.RESTScopeNamespace,
		GroupVersionKind: unversioned.GroupVersionKind{
			Kind:    "Pod",
			Version: "v1",
		}}

	client := &fake.RESTClient{
		Codec: testapi.Default.Codec(),
		Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
			header := http.Header{}
			header.Set("Content-Type", runtime.ContentTypeJSON)
			return &http.Response{
				StatusCode: 200,
				Header:     header,
				Body:       ioutil.NopCloser(bytes.NewReader(marshaledObj)),
			}, nil
		})}
	info := resource.NewInfo(client, mapping, "default", "nginx", false)

	info.Object = pod

	return info
}
Example #10
0
// setAllowHeader builds a Allow header based on the resource configuration.
func setAllowHeader(headers http.Header, isItem bool, conf resource.Conf) {
	methods := []string{}
	if isItem {
		// Methods are sorted
		if conf.IsModeAllowed(resource.Update) {
			methods = append(methods, "DELETE")
		}
		if conf.IsModeAllowed(resource.Read) {
			methods = append(methods, "GET, HEAD")
		}
		if conf.IsModeAllowed(resource.Update) {
			methods = append(methods, "PATCH")
			// See http://tools.ietf.org/html/rfc5789#section-3
			headers.Set("Allow-Patch", "application/json")
		}
		if conf.IsModeAllowed(resource.Create) || conf.IsModeAllowed(resource.Replace) {
			methods = append(methods, "PUT")
		}
	} else {
		// Methods are sorted
		if conf.IsModeAllowed(resource.Clear) {
			methods = append(methods, "DELETE")
		}
		if conf.IsModeAllowed(resource.List) {
			methods = append(methods, "GET, HEAD")
		}
		if conf.IsModeAllowed(resource.Create) {
			methods = append(methods, "POST")
		}
	}
	if len(methods) > 0 {
		headers.Set("Allow", strings.Join(methods, ", "))
	}
}
Example #11
0
func TestJWTAuthentication(t *testing.T) {
	m := minion.Classic(minion.Options{JWTToken: "123"})

	usersHandler := func(ctx *minion.Context) {
		j := struct {
			Message string `json:"message"`
		}{
			"ok",
		}
		ctx.JSON(200, j)
	}

	m.Get("/users", usersHandler)

	ts := httptest.NewServer(m)
	defer ts.Close()

	var j, body string
	var status int

	tokenString, _ := minion.CreateJWTToken(nil)

	h := http.Header{}
	h.Set("Authorization", "BEARER "+tokenString)

	status, body = tst.Request(t, ts, "GET", "/users", h, nil)
	tst.AssertEqual(t, 200, status)

	j = `{"message":"ok"}`
	tst.AssertEqual(t, j, body)
}
Example #12
0
func TestEnv(t *testing.T) {
	for k, c := range []struct {
		expectedIP    string
		expectedOwner string
		expectedUA    string
		request       *http.Request
		owner         string
		headers       map[string]string
	}{
		{"1234", "peter", "firefox", &http.Request{RemoteAddr: "1234"}, "peter", map[string]string{"user-Agent": "firefox"}},
		{"1234", "peter", "", &http.Request{RemoteAddr: "4321"}, "peter", map[string]string{"x-FoRwarded-FoR": "1234"}},
		{"1234", "peter", "firefox", &http.Request{RemoteAddr: "4321"}, "peter", map[string]string{"x-FoRwarded-FoR": "1234", "user-Agent": "firefox"}},
	} {
		h := http.Header{}
		for y, x := range c.headers {
			h.Set(y, x)
		}
		r := c.request
		r.Header = h
		t.Logf("%v", r)
		e := NewEnv(r)
		e.Owner(c.owner)
		assert.Equal(t, c.expectedIP, e.Ctx().ClientIP, "Case %d", k)
		assert.Equal(t, c.expectedOwner, e.Ctx().Owner, "Case %d", k)
		assert.Equal(t, c.expectedUA, e.Ctx().UserAgent, "Case %d", k)
	}
}
Example #13
0
// Here's the worker, of which we'll run several concurrent instances. Each
// worker will periodically make requests to the site to simulate users
// playing with it
func worker(done chan<- bool) {
	// First connect to the WebSocket server
	dialer := websocket.DefaultDialer
	header := http.Header{}
	header.Set("Origin", "http://bsprague.com")
	conn, _, err := dialer.Dial("ws://192.168.2.1:8080/ws", header)
	if err != nil {
		fmt.Println("Error connecting to server", err)
		done <- true
		return
	}

	defer conn.Close()
	go readLoop(conn)

	// Tick regularly somewhere between every 25 and 75 ms
	ticker := time.NewTicker(time.Millisecond * time.Duration(rand.Int63n(500)+250))

	for _ = range ticker.C {
		if err := conn.WriteJSON(randomBlock()); err != nil {
			fmt.Println("Error sending block", err)
			done <- true
			return
		}
	}

	done <- true
}
Example #14
0
// SetViaHeader sets the Via header.
//
// If Via is already present, via is appended to
// the existing value.
//
// http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#section-9.9
func SetViaHeader(header http.Header, via string) {
	if v := header.Get("Via"); v != "" {
		via = v + ", " + via
	}

	header.Set("Via", via)
}
Example #15
0
func (imageService Service) queryImages(includeDetails bool, imagesResponseContainer interface{}, queryParameters *QueryParameters) error {
	urlPostFix := "/images"
	if includeDetails {
		urlPostFix = urlPostFix + "/detail"
	}

	reqURL, err := buildQueryURL(imageService, queryParameters, urlPostFix)
	if err != nil {
		return err
	}

	var headers http.Header = http.Header{}
	headers.Set("Accept", "application/json")
	resp, err := imageService.Session.Get(reqURL.String(), nil, &headers)
	if err != nil {
		return err
	}

	err = util.CheckHTTPResponseStatusCode(resp)
	if err != nil {
		return err
	}

	rbody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return errors.New("aaa")
	}
	if err = json.Unmarshal(rbody, &imagesResponseContainer); err != nil {
		return err
	}
	return nil
}
Example #16
0
func copyHeaders(from, to http.Header) {
	for k, list := range from {
		for _, v := range list {
			to.Set(k, v)
		}
	}
}
Example #17
0
func (c *channel) createSubChannel(direction direction) (libchan.Sender, libchan.Receiver, error) {
	if c.direction == inbound {
		return nil, nil, errors.New("cannot create sub channel of an inbound channel")
	}
	referenceID := c.session.nextReferenceID()
	headers := http.Header{}
	headers.Set("libchan-ref", strconv.FormatUint(referenceID, 10))
	headers.Set("libchan-parent-ref", strconv.FormatUint(c.referenceID, 10))

	stream, streamErr := c.stream.CreateSubStream(headers, false)
	if streamErr != nil {
		return nil, nil, streamErr
	}
	subChannel := &channel{
		referenceID: referenceID,
		parentID:    c.referenceID,
		stream:      stream,
		session:     c.session,
		direction:   direction,
	}

	c.session.channelC.L.Lock()
	c.session.channels[referenceID] = subChannel
	c.session.channelC.L.Unlock()

	return subChannel, subChannel, nil
}
Example #18
0
func redditRequest(method string, url string, values url.Values, header http.Header) ([]byte, error) {
	form := strings.NewReader(values.Encode())

	req, err := http.NewRequest(method, url, form)
	if err != nil {
		return nil, err
	}

	header.Set("User-Agent", userAgent)
	header.Set("Content-Type", contentType)
	req.Header = header

	time.Sleep(timeBetweenRequests - time.Since(lastRequest))
	lastRequest = time.Now()
	fmt.Printf("Made request: %v\n", lastRequest)
	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}

	defer resp.Body.Close()
	data, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	return data, nil
}
Example #19
0
func ExampleCORSConfig() {
	// Simple Request using Test Browser
	r := NewRouter()
	r.SetGlobalCORS(CORSConfig{
		Origins:        []string{"*"},
		Methods:        []string{"POST", "PUT"},
		Headers:        []string{"X-Mangoes"},
		ExposedHeaders: []string{"X-Mangoes"},
	})

	r.Get("/fruits", func(c *Context) {
		c.RespondWith("GET fruits")
	})

	br := NewBrowser(r)
	hdrs := http.Header{}
	hdrs.Set("Origin", "http://bluecheese.com")
	resp, err := br.Get("http://greencheese.com/fruits", hdrs)

	if err != nil {
		fmt.Println(err)
		return
	}
	allowOrigin := resp.HeaderMap.Get("Access-Control-Allow-Origin")
	exposedHeaders := resp.HeaderMap.Get("Access-Control-Expose-Headers")
	fmt.Println(allowOrigin)
	fmt.Println(exposedHeaders)
	// Output:
	// http://bluecheese.com
	// X-Mangoes
}
Example #20
0
// Build the Image
func (c *ImageService) Build(tag, dir string) error {

	// tar the file
	context, err := archive.Tar(dir, archive.Uncompressed)
	if err != nil {
		return err
	}

	var body io.Reader
	body = ioutil.NopCloser(context)

	// Upload the build context
	v := url.Values{}
	v.Set("t", tag)
	v.Set("q", "1")
	v.Set("rm", "1")

	// url path
	path := fmt.Sprintf("/build?%s", v.Encode())

	// set content type to tar file
	headers := http.Header{}
	headers.Set("Content-Type", "application/tar")

	// make the request
	return c.stream("POST", path, body, os.Stdout, headers)
}
Example #21
0
func (s *Transport) createSubStream(parentID uint64) (*stream, error) {
	referenceID := atomic.AddUint64(&s.referenceCounter, 1)
	headers := http.Header{}
	headers.Set("libchan-ref", strconv.FormatUint(referenceID, 10))
	if parentID > 0 {
		headers.Set("libchan-parent-ref", strconv.FormatUint(parentID, 10))
	}

	providedStream, err := s.provider.NewStream(headers)
	if err != nil {
		return nil, err
	}

	newStream := &stream{
		referenceID: referenceID,
		parentID:    parentID,
		stream:      providedStream,
		session:     s,
	}

	// TODO: Do not store reference
	s.streamC.L.Lock()
	s.streams[referenceID] = newStream
	s.streamC.L.Unlock()

	return newStream, nil

}
Example #22
0
func valV2(r *http.Request, h http.Header, b *bytes.Buffer) *weft.Result {
	if res := weft.CheckQuery(r, []string{}, []string{}); !res.Ok {
		return res
	}

	var d string

	err := db.QueryRow(`SELECT row_to_json(fc)
                         FROM ( SELECT 'FeatureCollection' as type, array_to_json(array_agg(f)) as features
                         FROM (SELECT 'Feature' as type,
                         ST_AsGeoJSON(v.location)::json as geometry,
                         row_to_json((SELECT l FROM 
                         	(
                         		SELECT 
                                id AS "volcanoID",
                                title AS "volcanoTitle",
                                alert_level as "level",
                                activity,
                                hazards 
                           ) as l
                         )) as properties FROM (haz.volcano JOIN haz.volcanic_alert_level using (alert_level)) as v ) As f )  as fc`).Scan(&d)
	if err != nil {
		return weft.ServiceUnavailableError(err)
	}

	b.WriteString(d)
	h.Set("Content-Type", V2GeoJSON)
	return &weft.StatusOK
}
Example #23
0
func testGet(path string, headers map[string]string) *testResponse {
	var header http.Header
	for k, v := range headers {
		header.Set(k, v)
	}
	return getTestResponse("GET", path, "", header, nil)
}
Example #24
0
func volcanoRegionV2(r *http.Request, h http.Header, b *bytes.Buffer) *weft.Result {

	if res := weft.CheckQuery(r, []string{}, []string{}); !res.Ok {
		return res
	}

	var err error
	var volcanoId string

	if volcanoId, err = getVolcanoIDRegion(r); err != nil {
		return weft.BadRequest(err.Error())
	}

	var d string
	err = db.QueryRow(`SELECT row_to_json(fc)
			FROM ( SELECT 'FeatureCollection' as type, COALESCE(array_to_json(array_agg(f)), '[]') as features
			FROM (SELECT 'Feature' as type,
			ST_AsGeoJSON(r.region)::json as geometry,
			row_to_json((SELECT l FROM
			(
			SELECT	id,
			title
			) as l
			)) as properties
			FROM haz.volcano as r
			where id = $1) as f ) as fc;`, volcanoId).Scan(&d)
	if err != nil {
		return weft.ServiceUnavailableError(err)
	}

	b.WriteString(d)
	h.Set("Content-Type", V2GeoJSON)
	return &weft.StatusOK
}
Example #25
0
func (c *Client) GetFileContent(fileId, rangeEtag string, startIndex, endIndex int, matchEtags []string) ([]byte, *http.Header, error) {
	route := strings.Join([]string{FILE_ROUTE, fileId, "content"}, "/")
	link := c.getURL(route, "")

	// Construct header
	byteRange := fmt.Sprintf("bytes=%d-%d", startIndex, endIndex)
	newHeader := http.Header{}
	newHeader.Add("Range", byteRange)

	if rangeEtag != "" {
		newHeader.Set("If-Range", rangeEtag)
	}

	if len(matchEtags) > 0 {
		for _, v := range matchEtags {
			newHeader.Add("If-None-Match", v)
		}
	}

	res, err := c.request("GET", link, &newHeader, nil)
	if err != nil {
		return nil, nil, err
	}

	return unpackageResponse(res)
}
Example #26
0
// getAuthSession returns an authenticated API Session
func (d *driver) getAuthSession() (session *napping.Session, err error) {
	e := ApiError{}

	s := napping.Session{
		Userinfo: d.creds,
		Client:   d.httpClient,
	}

	url := d.url + loginUri

	resp, err := s.Get(url, nil, nil, &e)

	if err != nil {
		return
	}

	token := resp.HttpResponse().Header.Get("X-SDS-AUTH-TOKEN")

	h := http.Header{}

	h.Set("X-SDS-AUTH-TOKEN", token)

	session = &napping.Session{
		Client: d.httpClient,
		Header: &h,
	}

	return
}
Example #27
0
func quakeV2(r *http.Request, h http.Header, b *bytes.Buffer) *weft.Result {
	if res := weft.CheckQuery(r, []string{}, []string{}); !res.Ok {
		return res
	}

	if len(r.URL.Query()) != 0 {
		return weft.BadRequest("incorrect number of query parameters.")
	}

	var publicID string
	var res *weft.Result

	if publicID, res = getPublicIDPath(r); !res.Ok {
		return res
	}

	var d string
	err := db.QueryRow(quakeV2SQL, publicID).Scan(&d)
	if err != nil {
		return weft.ServiceUnavailableError(err)
	}

	b.WriteString(d)
	h.Set("Content-Type", V2GeoJSON)
	return &weft.StatusOK
}
Example #28
0
// TranscribeWithIBM transcribes a given audio file using the IBM Watson
// Speech To Text API
func TranscribeWithIBM(filePath string, searchWords []string, IBMUsername string, IBMPassword string) (*IBMResult, error) {
	result := new(IBMResult)

	url := "wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize?model=en-US_BroadbandModel"
	header := http.Header{}
	header.Set("Authorization", "Basic "+basicAuth(IBMUsername, IBMPassword))

	dialer := websocket.DefaultDialer
	ws, _, err := dialer.Dial(url, header)
	if err != nil {
		return nil, errors.Trace(err)
	}
	defer ws.Close()

	requestArgs := map[string]interface{}{
		"action":             "start",
		"content-type":       "audio/flac",
		"continuous":         true,
		"word_confidence":    true,
		"timestamps":         true,
		"profanity_filter":   false,
		"interim_results":    false,
		"inactivity_timeout": -1,
		"keywords":           searchWords,
		"keywords_threshold": 0.5,
	}

	if err = ws.WriteJSON(requestArgs); err != nil {
		return nil, errors.Trace(err)
	}
	log.Debug("Starting transcription using IBM")

	if err = uploadFileWithWebsocket(ws, filePath); err != nil {
		return nil, errors.Trace(err)
	}
	log.Debugf("Successfully uploaded %s to IBM", filePath)

	// write empty message to indicate end of uploading file
	if err = ws.WriteMessage(websocket.BinaryMessage, []byte{}); err != nil {
		return nil, errors.Trace(err)
	}

	// IBM must receive a message every 30 seconds or it will close the websocket.
	// This code concurrently writes a message every 5 second until returning.
	ticker := time.NewTicker(5 * time.Second)
	quit := make(chan struct{})
	go keepConnectionOpen(ws, ticker, quit)
	defer close(quit)

	for {
		err := ws.ReadJSON(&result)
		if err != nil {
			return nil, errors.Trace(err)
		}
		if len(result.Results) > 0 {
			log.Debugf("IBM has returned results")
			return result, nil
		}
	}
}
Example #29
0
File: json.go Project: devick/flynn
func (c *Client) prepareReq(method, rawurl string, header http.Header, in interface{}) (*http.Request, error) {
	var payload io.Reader
	switch v := in.(type) {
	case io.Reader:
		payload = v
	case nil:
	default:
		var err error
		payload, err = ToJSON(in)
		if err != nil {
			return nil, err
		}
	}

	req, err := http.NewRequest(method, rawurl, payload)
	if err != nil {
		return nil, err
	}
	if header == nil {
		header = make(http.Header)
	}
	if header.Get("Content-Type") == "" {
		header.Set("Content-Type", "application/json")
	}
	req.Header = header
	if c.Key != "" {
		req.SetBasicAuth("", c.Key)
	}
	if c.Host != "" {
		req.Host = c.Host
	}
	return req, nil
}
Example #30
0
func quakeProto(r *http.Request, h http.Header, b *bytes.Buffer) *weft.Result {
	if res := weft.CheckQuery(r, []string{}, []string{}); !res.Ok {
		return res
	}

	var q haz.Quake
	var res *weft.Result

	if q.PublicID, res = getPublicIDPath(r); !res.Ok {
		return res
	}

	var t time.Time
	var mt time.Time
	var err error

	if err = db.QueryRow(quakeProtoSQL, q.PublicID).Scan(&t, &mt,
		&q.Depth, &q.Magnitude, &q.Locality, &q.Mmi, &q.Quality,
		&q.Longitude, &q.Latitude); err != nil {
		return weft.ServiceUnavailableError(err)
	}

	q.Time = &haz.Timestamp{Sec: t.Unix(), Nsec: int64(t.Nanosecond())}
	q.ModificationTime = &haz.Timestamp{Sec: mt.Unix(), Nsec: int64(mt.Nanosecond())}

	var by []byte

	if by, err = proto.Marshal(&q); err != nil {
		return weft.ServiceUnavailableError(err)
	}

	b.Write(by)
	h.Set("Content-Type", protobuf)
	return &weft.StatusOK
}