You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@htrace.apache.org by cm...@apache.org on 2015/01/02 23:15:47 UTC

incubator-htrace git commit: HTRACE-47. Add Content-Type header in htraced REST server (Abraham Elmahrek via Colin P. McCabe)

Repository: incubator-htrace
Updated Branches:
  refs/heads/master a852600af -> 1562b9764


HTRACE-47. Add Content-Type header in htraced REST server (Abraham Elmahrek via Colin P. McCabe)


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/1562b976
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/1562b976
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/1562b976

Branch: refs/heads/master
Commit: 1562b976422f7c7b5d2f245b0dee144f5b56193b
Parents: a852600
Author: Colin P. Mccabe <cm...@apache.org>
Authored: Fri Jan 2 14:14:37 2015 -0800
Committer: Colin P. Mccabe <cm...@apache.org>
Committed: Fri Jan 2 14:14:37 2015 -0800

----------------------------------------------------------------------
 htrace-core/src/go/src/org/apache/htrace/htraced/rest.go | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/1562b976/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go
----------------------------------------------------------------------
diff --git a/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go b/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go
index 74018c0..73409fe 100644
--- a/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go
+++ b/htrace-core/src/go/src/org/apache/htrace/htraced/rest.go
@@ -22,10 +22,12 @@ package main
 import (
 	"encoding/json"
 	"log"
+	"mime"
 	"net/http"
 	"org/apache/htrace/common"
 	"org/apache/htrace/conf"
 	"org/apache/htrace/resource"
+	"path/filepath"
 	"strconv"
 	"strings"
 )
@@ -140,6 +142,9 @@ func (hand *defaultServeHandler) ServeHTTP(w http.ResponseWriter, req *http.Requ
 		w.WriteHeader(http.StatusNotFound)
 		return
 	}
+	file_ext := filepath.Ext(req.URL.Path)
+	mime_type := mime.TypeByExtension(file_ext)
+	w.Header().Set("Content-Type", mime_type)
 	w.Write([]byte(rsc))
 }