Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3851

Golang thrift continually adds the x/thrift content type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.10.0
    • Go - Library
    • None

    Description

      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
      }
      
       	p.header.Add("Content-Type", "application/x-thrift") 

      This adds the content-type to the httpClient which is then assigned to every request. This causes the header to get larger and larger causing some servers to reject requests due to header size (e.g. Apache Aurora)

      Attachments

        Issue Links

          Activity

            People

              connorgorman Connor Gorman
              connorgorman Connor Gorman
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: