X-Cache Header Explanation

CDN (Content Delivery Network) adds X-cache header to HTTP Response. X-cache:HIT means that your request was served by CDN, not origin servers. CDN is a special network designed to cache content, so that usr request served faster + to unload origin servers.

HTTP basic authentication over SSL for REST API

Basic authentification is just a standard HTTP header with the user and pass encoded in base64 : Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== (http://en.wikipedia.org/wiki/Basic_access_authentication) .If you authenticate your rest API calls by this header over a non ssl conection, the problem is that any man in the middle can decode your username and password from your auth header. … Read more

How can I rewrite this CURL multipart/form-data request without using -F?

Solved: curl \ -X POST \ -H “Content-Type: multipart/form-data; boundary=—————————-4ebf00fbcf09″ \ –data-binary @test.txt \ http://localhost:3000/test Where test.txt contains the following text, and most importantly has CRLF (\r\n) line endings: ——————————4ebf00fbcf09 Content-Disposition: form-data; name=”example” test ——————————4ebf00fbcf09– Notes: it is important to use –data-binary instead of plain old -d as the former preserves the line endings (which … Read more

Not buffered http.ResponseWritter in Golang

As implied in the documentation, some ResponseWriter may implement the Flusher interface. This means you can do something like this : func handle(res http.ResponseWriter, req *http.Request) { fmt.Fprintf(res, “sending first line of data”) if f, ok := res.(http.Flusher); ok { f.Flush() } else { log.Println(“Damn, no flush”); } sleep(10) //not real code fmt.Fprintf(res, “sending second … Read more

HTTPbis – what does bis mean?

As others have already said, “bis” comes from “twice” or “repeat”. It’s used to indicate a second variant of something (although usually with only minor variations that don’t warrant a new name). In the context of HTTP, HTTPbis is the name of the working group in charge of refining HTTP. According to its charter: HTTP … Read more

Serving gzipped content for Go

The New York Times have released their gzip middleware package for Go. You just pass your http.HandlerFunc through their GzipHandler and you’re done. It looks like this: package main import ( “io” “net/http” “github.com/nytimes/gziphandler” ) func main() { withoutGz := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set(“Content-Type”, “text/plain”) io.WriteString(w, “Hello, World”) }) withGz := gziphandler.GzipHandler(withoutGz) http.Handle(“https://stackoverflow.com/”, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)