@Override public boolean onPrepareTransmission(PortTransmitter transmitter) { transmitter.putLine( "HTTP/" + response.version + " " + response.responseStatusCode + " " + response.responseStatusText, Charset.defaultCharset()); for (Map.Entry<String, String> header : response.headers.entrySet()) { transmitter.putLine(header.getKey() + ": " + header.getValue(), Charset.defaultCharset()); } transmitter.putLine("", Charset.defaultCharset()); return true; }
@Override public boolean onTransmitterReady(DigitalPort port, PortTransmitter transmitter) { if (response.data == null) { return true; } else { transmitter.putBuffer(response.data); return !response.data.hasRemaining(); } }