Skip to content

Commit b4bb62b

Browse files
authored
Merge pull request #2447 from lebauce/orientdb-gzip
Fix orientdb gzip compression
2 parents bfd8cdf + 7cf30e5 commit b4bb62b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

graffiti/storage/orientdb/client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ func (c *Client) Request(method string, url string, body io.Reader) (*http.Respo
320320
return nil, err
321321
}
322322

323+
if body != nil {
324+
request.Header.Set("Content-Encoding", "gzip")
325+
}
326+
323327
if !c.authenticated {
324328
request.SetBasicAuth(c.username, c.password)
325329
} else {
@@ -555,7 +559,7 @@ func (c *Client) CreateDatabase() (*Result, error) {
555559
// SQL Simple Query Language, send a query to the OrientDB server
556560
func (c *Client) SQL(query string) (*Result, error) {
557561
url := fmt.Sprintf("%s/command/%s/sql", c.url, c.database)
558-
resp, err := c.Request("POST", url, bytes.NewBufferString(query))
562+
resp, err := c.Request("POST", url, strings.NewReader(query))
559563
if err != nil {
560564
return nil, err
561565
}
@@ -604,7 +608,7 @@ func (c *Client) reconnect() error {
604608

605609
defer resp.Body.Close()
606610
if resp.StatusCode >= 400 {
607-
return fmt.Errorf("Failed to authenticate to OrientDB: %s", resp.Status)
611+
return fmt.Errorf("failed to authenticate to OrientDB: %s", resp.Status)
608612
}
609613

610614
if resp.StatusCode < 400 && len(resp.Cookies()) != 0 {

0 commit comments

Comments
 (0)