private byte[] sendHttpMessage(byte[] body) throws IOException { HttpMessageContext context = HttpMessageContext.getInstance(); context.Debug("GNHttpConnection [sendHttpMessage] starts"); if (context.getLogheader()) { context.Info(logMessageSetting()); } connection.setDoInput(true); if (body != null) { connection.setDoOutput(true); OutputStream os = TimedURLConnection.getOutputStream(connection, timeout * 1000); context.Debug("GNHttpConnection [sendHttpMessage] sending message ..."); os.write(body); context.Debug("GNHttpConnection [sendHttpMessage] message sent"); } context.Debug( "GNHttpConnection [sendHttpMessage] TimedURLConnection.getInputStream timeout[" + timeout + " S]"); InputStream is = TimedURLConnection.getInputStream(connection, timeout * 1000); responseCode = connection.getResponseCode(); context.Debug("GNHttpConnection [sendHttpMessage] responseCode[" + responseCode + "]"); responseMessage = HttpMessageContext.getMessage(is); responseheaders = new Hashtable<String, String>(); int no = 0; while (true) { String headerName = connection.getHeaderFieldKey(no); String headerValue = connection.getHeaderField(no); if (headerName != null && headerName.length() > 0) { responseheaders.put(headerName, headerValue); } else { if (headerValue == null || headerValue.length() <= 0) break; } no++; } if (context.getLogheader()) { GTConfigFile head = new GTConfigFile(responseheaders); context.Debug("GNHttpConnection [sendHttpMessage] responseHeader\r\n" + head); context.Debug( "GNHttpConnection [sendHttpMessage] responseMessage\r\n" + new String(getResponseMessage())); context.Info("GNHttpConnection [sendHttpMessage] success for " + url); } else context.Info("GNHttpConnection [sendHttpMessage] success for " + url); return responseMessage; }
protected byte[] sendHttpMessage(Hashtable headers, byte[] body) throws IOException { HttpMessageContext context = HttpMessageContext.getInstance(); setVerb(getRequestMethod()); context.Debug("GNHttpConnection [sendHttpMessage] Method[" + getRequestMethod() + "]"); addRequestHeaders(headers); if (context.getLogheader() && headers != null) { GTConfigFile head = new GTConfigFile(headers); context.Debug("GNHttpConnection [sendHttpMessage] requestHeader\r\n" + head); } return sendHttpMessage(body); }