| | |
| | | */ |
| | | public class NyHttpUtils { |
| | | |
| | | private static final boolean DEBUG = true;//调试模式 |
| | | |
| | | //获取HTTP请求标准结构体 |
| | | public static NyShuttleHttpCommand getHttpStandard(Integer shuttleNo, Integer wrkNo) { |
| | | NyShuttleHttpCommand httpStandard = new NyShuttleHttpCommand(); |
| | |
| | | } |
| | | |
| | | //发出请求 |
| | | public static JSONObject requestCommand(Socket socket, NyShuttleHttpCommand httpCommand) { |
| | | try { |
| | | public static JSONObject requestCommand(Socket socket, NyShuttleHttpCommand httpCommand) throws IOException { |
| | | if (socket == null) { |
| | | return null; |
| | | } |
| | |
| | | JSONObject resultResponse = JSON.parseObject(result.get("response").toString()); |
| | | JSONObject resultHeader = JSON.parseObject(resultResponse.get("header").toString()); |
| | | int responseId = Integer.parseInt(resultHeader.get("responseId").toString()); |
| | | // if (responseId != httpCommand.getRequest().getHeader().getRequestId()) { |
| | | // return null;//响应ID与请求ID不一致 |
| | | // } |
| | | if (!DEBUG && responseId != httpCommand.getRequest().getHeader().getRequestId()) { |
| | | return null;//响应ID与请求ID不一致,不在调试模式下 |
| | | } |
| | | |
| | | return filterBodyData(result);//返回Body结果集 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | try { |
| | | socket.close(); |
| | | } catch (IOException exception) { |
| | | exception.printStackTrace(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static JSONObject filterBodyData(JSONObject data) { |