diff --git a/realis.go b/realis.go index 339f07e..87b904c 100644 --- a/realis.go +++ b/realis.go @@ -31,6 +31,8 @@ import ( "github.com/rdelval/gorealis/response" ) +const VERSION = "1.0.4" + type Realis interface { AbortJobUpdate(updateKey aurora.JobUpdateKey, message string) (*aurora.Response, error) AddInstances(instKey aurora.InstanceKey, count int32) (*aurora.Response, error) @@ -225,6 +227,7 @@ func newTJSONConfig(url string, timeoutms int) (*RealisConfig, error) { httpTrans := (trans).(*thrift.THttpClient) httpTrans.SetHeader("Content-Type", "application/x-thrift") + httpTrans.SetHeader("User-Agent", "GoRealis v"+VERSION) return &RealisConfig{transport: trans, protoFactory: thrift.NewTJSONProtocolFactory()}, nil } @@ -237,9 +240,11 @@ func newTBinaryConfig(url string, timeoutms int) (*RealisConfig, error) { } httpTrans := (trans).(*thrift.THttpClient) + httpTrans.DelHeader("Content-Type") // Workaround for using thrift HttpPostClient + httpTrans.SetHeader("Accept", "application/vnd.apache.thrift.binary") httpTrans.SetHeader("Content-Type", "application/vnd.apache.thrift.binary") - httpTrans.SetHeader("User-Agent", "GoRealis v1.0.4") + httpTrans.SetHeader("User-Agent", "GoRealis v"+VERSION) return &RealisConfig{transport: trans, protoFactory: thrift.NewTBinaryProtocolFactoryDefault()}, nil diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go b/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go index f47b3cf..88eb2c1 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go +++ b/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go @@ -103,7 +103,7 @@ func NewTHttpClientWithOptions(urlstr string, options THttpClientOptions) (TTran if client == nil { client = DefaultHttpClient } - httpHeader := map[string][]string{} + httpHeader := map[string][]string{"Content-Type": []string{"application/x-thrift"}} return &THttpClient{client: client, response: response, url: parsedURL, header: httpHeader}, nil } @@ -121,7 +121,7 @@ func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (T if client == nil { client = DefaultHttpClient } - httpHeader := map[string][]string{} + httpHeader := map[string][]string{"Content-Type": []string{"application/x-thrift"}} return &THttpClient{client: client, url: parsedURL, requestBuffer: bytes.NewBuffer(buf), header: httpHeader}, nil }