0

I'm trying to send a compressed file through AppEngine, my function is

func handleWebGLRequest(w http.ResponseWriter, r *http.Request) {
    c := appengine.NewContext(r)

    blobKey, err := blobstore.BlobKeyForFile(c, "/gs/<path>/WebGL.datagz")
    if err != nil {
        fmt.Fprintf(w, "Problem: cannot find WebGL.data")
        return
    }

    w.Header().Set("Content-Type", "blah/blah/application/octet-stream")
    w.Header().Set("Content-Encoding", "gzip")
    blobstore.Send(w, blobKey)
}

The file is sent, the content-type appears correctly in the response header with "blah/blah/application/octet-stream", but Content-Encoding is never in the response header, which (I think) is the cause of other issues I'm having.

Does anyone know why it doesn't work?

(In case it matters - I'm using chrome inspector to view the response headers, and here it is, source not parsed

HTTP/1.1 200 OK Content-Type: blah/blah/application/octet-stream Transfer-Encoding: chunked Date: Tue, 28 Apr 2015 06:50:09 GMT Server: Google Frontend Alternate-Protocol: 80:quic,p=1)

Much appreciated

Adam Zeira
  • 33
  • 5

1 Answers1

1

You can't control this header, the servers actually try to serve gzipped content as frequently as possible, as long as they're confident the browser will support it.

How do I serve compressed content?

Google App Engine does its best to serve gzipped content to browsers that support it. Taking advantage of this scheme is automatic and requires no modifications to applications.

Community
  • 1
  • 1
Jaime Gómez
  • 6,961
  • 3
  • 40
  • 41
  • 1
    That makes sense. To add to the answer, on Cloud Storage you *can* control Content-Encoding (files on Cloud Storage can be put in zipped or non-zipped state and will stay that way, you must set the metadata yourself including Content-Encoding). it's possible to redirect to it, but in most situations that will create cross-domain policy issues – Adam Zeira Apr 28 '15 at 09:32