[tor-commits] [meek/master] Set Content-Type: application/octet-stream in meek-server.

dcf at torproject.org dcf at torproject.org
Tue Sep 9 06:16:25 UTC 2014


commit fa5fbb807a5d81cd234caf402f262d4a5de0533e
Author: David Fifield <david at bamsoftware.com>
Date:   Mon Aug 4 00:27:07 2014 -0700

    Set Content-Type: application/octet-stream in meek-server.
    
    Even thought it takes up space in the header, it looks like Google and
    Amazon try to sniff the type and add the header anyway if it is missing.
    (They set "text/plain; charset=utf-8" for zero-length bodies and
    "application/octet-stream" for non-zero bodies). So we might as well add
    it preemptively.
    
    https://trac.torproject.org/projects/tor/ticket/12778
---
 meek-server/meek-server.go |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/meek-server/meek-server.go b/meek-server/meek-server.go
index b0c9fa3..4edf850 100644
--- a/meek-server/meek-server.go
+++ b/meek-server/meek-server.go
@@ -164,6 +164,8 @@ func transact(session *Session, w http.ResponseWriter, req *http.Request) error
 		}
 	}
 	// log.Printf("read %d bytes from ORPort: %q", n, buf[:n])
+	// Set a Content-Type to prevent Go and the CDN from trying to guess.
+	w.Header().Set("Content-Type", "application/octet-stream")
 	n, err = w.Write(buf[:n])
 	if err != nil {
 		return errors.New(fmt.Sprintf("writing to response: %s", err))



More information about the tor-commits mailing list