[ 
https://issues.apache.org/jira/browse/THRIFT-3851?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Connor Gorman updated THRIFT-3851:
----------------------------------
    Description: 
{code}
func (p *THttpClient) Flush() error {
        // Close any previous response body to avoid leaking connections.
        p.closeResponse()

        req, err := http.NewRequest("POST", p.url.String(), p.requestBuffer)
        if err != nil {
                return NewTTransportExceptionFromError(err)
        }
        p.header.Add("Content-Type", "application/x-thrift")
        req.Header = p.header
        response, err := p.client.Do(req)
        if err != nil {
                return NewTTransportExceptionFromError(err)
        }
        if response.StatusCode != http.StatusOK {
                // Close the response to avoid leaking file descriptors. 
closeResponse does
                // more than just call Close(), so temporarily assign it and 
reuse the logic.
                p.response = response
                p.closeResponse()

                // TODO(pomack) log bad response
                return NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, 
"HTTP Response code: "+strconv.Itoa(response.StatusCode))
        }
        p.response = response
        return nil
}
{code}
This adds the content-type to every message and the header will get larger and 
larger causing some servers to reject requests after a certain amount of 
requests

  was:
func (p *THttpClient) Flush() error {
        // Close any previous response body to avoid leaking connections.
        p.closeResponse()

        req, err := http.NewRequest("POST", p.url.String(), p.requestBuffer)
        if err != nil {
                return NewTTransportExceptionFromError(err)
        }
        p.header.Add("Content-Type", "application/x-thrift")
        req.Header = p.header
        response, err := p.client.Do(req)
        if err != nil {
                return NewTTransportExceptionFromError(err)
        }
        if response.StatusCode != http.StatusOK {
                // Close the response to avoid leaking file descriptors. 
closeResponse does
                // more than just call Close(), so temporarily assign it and 
reuse the logic.
                p.response = response
                p.closeResponse()

                // TODO(pomack) log bad response
                return NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, 
"HTTP Response code: "+strconv.Itoa(response.StatusCode))
        }
        p.response = response
        return nil
}

This adds the content-type to every message and the header will get larger and 
larger causing some servers to reject requests after a certain amount of 
requests


> Golang thrift continually adds the x/thrift content type 
> ---------------------------------------------------------
>
>                 Key: THRIFT-3851
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3851
>             Project: Thrift
>          Issue Type: Bug
>            Reporter: Connor Gorman
>
> {code}
> func (p *THttpClient) Flush() error {
>       // Close any previous response body to avoid leaking connections.
>       p.closeResponse()
>       req, err := http.NewRequest("POST", p.url.String(), p.requestBuffer)
>       if err != nil {
>               return NewTTransportExceptionFromError(err)
>       }
>       p.header.Add("Content-Type", "application/x-thrift")
>       req.Header = p.header
>       response, err := p.client.Do(req)
>       if err != nil {
>               return NewTTransportExceptionFromError(err)
>       }
>       if response.StatusCode != http.StatusOK {
>               // Close the response to avoid leaking file descriptors. 
> closeResponse does
>               // more than just call Close(), so temporarily assign it and 
> reuse the logic.
>               p.response = response
>               p.closeResponse()
>               // TODO(pomack) log bad response
>               return NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, 
> "HTTP Response code: "+strconv.Itoa(response.StatusCode))
>       }
>       p.response = response
>       return nil
> }
> {code}
> This adds the content-type to every message and the header will get larger 
> and larger causing some servers to reject requests after a certain amount of 
> requests



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to