Added download speed-test endpoint
This commit is contained in:
parent
e3f14801e9
commit
cd19477153
@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'de.w665'
|
group = 'de.w665'
|
||||||
version = '0.0.1'
|
version = '0.0.2'
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = '21'
|
sourceCompatibility = '21'
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package de.w665.sharepulse.rest.mappings;
|
||||||
|
|
||||||
|
import de.w665.sharepulse.rest.ApiRestController;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
public class SpeedTest extends ApiRestController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to test the download speed of the client. 1MB of dummy data is sent to the client.
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
@GetMapping("/speed-test")
|
||||||
|
public void speedTest(HttpServletResponse response) {
|
||||||
|
byte[] dummyData = new byte[1024 * 1024];
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.setContentLength(dummyData.length);
|
||||||
|
response.setStatus(HttpServletResponse.SC_OK);
|
||||||
|
try {
|
||||||
|
response.getOutputStream().write(dummyData);
|
||||||
|
response.getOutputStream().flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Speed test failed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user