package pwc.taxtech.atms.controller; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import pwc.taxtech.atms.dto.ConnectionData; @RestController @RequestMapping("/signalr/") public class DummyNegotiateController { @RequestMapping(value = "negotiate", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public void getUserPermission(@RequestParam("clientProtocol") String clientProtocol, @RequestBody(required = false) ConnectionData connecitonData, HttpServletResponse response) throws IOException { // 关闭websocket response.sendError(400, "__Negotiate Aborted__"); // ClassPathResource resource = new ClassPathResource("dummyJson/negotiate.json"); // byte[] buffer = new byte[1024]; // InputStream inputStream = resource.getInputStream(); // OutputStream output = response.getOutputStream(); // response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); // for(int length = 0; (length = inputStream.read(buffer)) > 0;) { // output.write(buffer, 0, length); // } } }