Skip to content

Commit

Permalink
some changes made to add the response headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranav-b-7 committed Jan 8, 2021
1 parent 20daca1 commit 0910831
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CorsFilter implements Filter {
response.setHeader("Access-Control-Allow-Origin", origin)
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT, PATCH")
response.setHeader("Access-Control-Max-Age", "3600")
response.setHeader("Access-Control-Allow-Headers", "x-requested-with, content-type, authorization, X-RateLimit-App, X-Spinnaker-Priority")
response.setHeader("Access-Control-Allow-Headers", "x-requested-with, content-type, authorization, X-RateLimit-App, X-Spinnaker-Priority, Content-Disposition")
response.setHeader("Access-Control-Expose-Headers", [Headers.AUTHENTICATION_REDIRECT_HEADER_NAME].join(", "))
chain.doFilter(req, res)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ import okhttp3.Request
import org.apache.commons.io.IOUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
import org.springframework.http.HttpHeaders
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
import retrofit.client.Response

import java.util.stream.Collectors

@RequestMapping("/autopilot")
@RestController
@Slf4j
Expand Down Expand Up @@ -70,7 +74,10 @@ class OpsmxAutopilotController {
InputStream inputStream = response.getBody().in()
try {
byte [] zipFile = IOUtils.toByteArray(inputStream)
return zipFile
HttpHeaders headers = new HttpHeaders()
headers.add("Content-Disposition", response.getHeaders().stream().filter({ header -> header.getName().trim().equalsIgnoreCase("Content-Disposition") }).collect(Collectors.toList()).get(0).value)
return ResponseEntity.ok().headers(headers).body(zipFile)

} finally{
if (inputStream!=null){
inputStream.close()
Expand Down

0 comments on commit 0910831

Please sign in to comment.