You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2017/07/11 21:10:55 UTC
thrift git commit: THRIFT-4219 remove http GET functions,
Thrift only uses POST Client: Go Patch: D. Can Celasun
Repository: thrift
Updated Branches:
refs/heads/master 5e9209ff0 -> 0dd823580
THRIFT-4219 remove http GET functions, Thrift only uses POST
Client: Go
Patch: D. Can Celasun <dc...@gmail.com>
This closes #1287
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/0dd82358
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/0dd82358
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/0dd82358
Branch: refs/heads/master
Commit: 0dd823580c78a79ae9696eb9b3650e400fff140f
Parents: 5e9209f
Author: D. Can Celasun <dc...@gmail.com>
Authored: Sat Jun 10 16:37:47 2017 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Tue Jul 11 23:10:05 2017 +0200
----------------------------------------------------------------------
lib/go/thrift/http_client.go | 62 +++++++++++++++------------------------
1 file changed, 23 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/0dd82358/lib/go/thrift/http_client.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/http_client.go b/lib/go/thrift/http_client.go
index b7ca274..33f2aa4 100644
--- a/lib/go/thrift/http_client.go
+++ b/lib/go/thrift/http_client.go
@@ -46,22 +46,15 @@ type THttpClient struct {
type THttpClientTransportFactory struct {
options THttpClientOptions
url string
- isPost bool
}
func (p *THttpClientTransportFactory) GetTransport(trans TTransport) (TTransport, error) {
if trans != nil {
t, ok := trans.(*THttpClient)
if ok && t.url != nil {
- if t.requestBuffer != nil {
- return NewTHttpPostClientWithOptions(t.url.String(), p.options)
- }
return NewTHttpClientWithOptions(t.url.String(), p.options)
}
}
- if p.isPost {
- return NewTHttpPostClientWithOptions(p.url, p.options)
- }
return NewTHttpClientWithOptions(p.url, p.options)
}
@@ -75,15 +68,7 @@ func NewTHttpClientTransportFactory(url string) *THttpClientTransportFactory {
}
func NewTHttpClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory {
- return &THttpClientTransportFactory{url: url, isPost: false, options: options}
-}
-
-func NewTHttpPostClientTransportFactory(url string) *THttpClientTransportFactory {
- return NewTHttpPostClientTransportFactoryWithOptions(url, THttpClientOptions{})
-}
-
-func NewTHttpPostClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory {
- return &THttpClientTransportFactory{url: url, isPost: true, options: options}
+ return &THttpClientTransportFactory{url: url, options: options}
}
func NewTHttpClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) {
@@ -91,27 +76,6 @@ func NewTHttpClientWithOptions(urlstr string, options THttpClientOptions) (TTran
if err != nil {
return nil, err
}
- response, err := http.Get(urlstr)
- if err != nil {
- return nil, err
- }
- client := options.Client
- if client == nil {
- client = DefaultHttpClient
- }
- httpHeader := map[string][]string{"Content-Type": {"application/x-thrift"}}
- return &THttpClient{client: client, response: response, url: parsedURL, header: httpHeader}, nil
-}
-
-func NewTHttpClient(urlstr string) (TTransport, error) {
- return NewTHttpClientWithOptions(urlstr, THttpClientOptions{})
-}
-
-func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) {
- parsedURL, err := url.Parse(urlstr)
- if err != nil {
- return nil, err
- }
buf := make([]byte, 0, 1024)
client := options.Client
if client == nil {
@@ -121,8 +85,8 @@ func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (T
return &THttpClient{client: client, url: parsedURL, requestBuffer: bytes.NewBuffer(buf), header: httpHeader}, nil
}
-func NewTHttpPostClient(urlstr string) (TTransport, error) {
- return NewTHttpPostClientWithOptions(urlstr, THttpClientOptions{})
+func NewTHttpClient(urlstr string) (TTransport, error) {
+ return NewTHttpClientWithOptions(urlstr, THttpClientOptions{})
}
// Set the HTTP Header for this specific Thrift Transport
@@ -252,3 +216,23 @@ func (p *THttpClient) RemainingBytes() (num_bytes uint64) {
const maxSize = ^uint64(0)
return maxSize // the thruth is, we just don't know unless framed is used
}
+
+// Deprecated: Use NewTHttpClientTransportFactory instead.
+func NewTHttpPostClientTransportFactory(url string) *THttpClientTransportFactory {
+ return NewTHttpClientTransportFactoryWithOptions(url, THttpClientOptions{})
+}
+
+// Deprecated: Use NewTHttpClientTransportFactoryWithOptions instead.
+func NewTHttpPostClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory {
+ return NewTHttpClientTransportFactoryWithOptions(url, options)
+}
+
+// Deprecated: Use NewTHttpClientWithOptions instead.
+func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) {
+ return NewTHttpClientWithOptions(urlstr, options)
+}
+
+// Deprecated: Use NewTHttpClient instead.
+func NewTHttpPostClient(urlstr string) (TTransport, error) {
+ return NewTHttpClientWithOptions(urlstr, THttpClientOptions{})
+}