Skip to content

Commit

Permalink
Merge pull request #92 from eyalbe4/dev
Browse files Browse the repository at this point in the history
Set the "X-Accel-Buffering" header to "no" for Xray scan builds reque…
  • Loading branch information
eyalbe4 authored Nov 3, 2019
2 parents 0742b87 + 3bbfd57 commit 9ccd99c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions artifactory/services/utils/artifactoryutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func SetContentType(contentType string, headers *map[string]string) {
AddHeader("Content-Type", contentType, headers)
}

func DisableAccelBuffering(headers *map[string]string) {
AddHeader("X-Accel-Buffering", "no", headers)
}

func AddHeader(headerName, headerValue string, headers *map[string]string) {
if *headers == nil {
*headers = make(map[string]string)
Expand Down
8 changes: 8 additions & 0 deletions artifactory/services/xrayscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ func (ps *XrayScanService) execScanRequest(url string, content []byte) (*http.Re
httpClientsDetails := ps.ArtDetails.CreateHttpClientDetails()
utils.SetContentType("application/json", &httpClientsDetails.Headers)

// The scan build operation can take a long time to finish.
// To keep the connection open, when Xray starts scanning the build, it starts sending new-lines
// on the open channel. This tells the client that the operation is still in progress and the
// connection does not get timed out.
// We need make sure the new-lines are not buffered on the nginx and are flushed
// as soon as Xray sends them.
utils.DisableAccelBuffering(&httpClientsDetails.Headers)

resp, _, _, err := ps.client.Send("POST", url, content, true, false, &httpClientsDetails)
if err != nil {
return resp, err
Expand Down

0 comments on commit 9ccd99c

Please sign in to comment.