Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

SPR-16754 InputStream has already been read #178

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions SPR-16754/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

mvn spring-boot:run
curl localhost:8080/ -H "Range:bytes=1-"
25 changes: 25 additions & 0 deletions SPR-16754/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fix-spring</groupId>
<artifactId>spr16754</artifactId>
<version>0.0.1-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>

<properties>
<java-version>1.8</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
32 changes: 32 additions & 0 deletions SPR-16754/src/main/java/spr16754/SPR16754.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package spr16754;

import static org.springframework.http.ResponseEntity.ok;

import java.io.InputStream;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.ResponseEntity.BodyBuilder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@SpringBootApplication
@Controller
public class SPR16754 {

public static void main(String[] args) {
SpringApplication.run(SPR16754.class, args);
}

@GetMapping("/")
public ResponseEntity<InputStreamResource> download() {
InputStream stream = getClass().getResourceAsStream("/blob");
BodyBuilder builder = ok();
builder.contentType(MediaType.APPLICATION_OCTET_STREAM);
return builder.body(new InputStreamResource(stream));
}

}
Binary file added SPR-16754/src/main/resources/blob
Binary file not shown.