/** * Wait for the SharedOutputBuffer to become available, write audio data to it. */ public void run() { this.logger = MaryUtils.getLogger(Thread.currentThread().getName()); // We must wait until produceContent() is called: while (out == null) { synchronized (mutex) { try { mutex.wait(); } catch (InterruptedException e) { } } } assert out != null; ContentOutputStream outStream = new ContentOutputStream(out); try { AudioSystem.write(audio, audioType, outStream); outStream.flush(); outStream.close(); logger.info("Finished writing output"); } catch (IOException ioe) { logger.info("Cannot write output, client seems to have disconnected. ", ioe); maryRequest.abort(); } } }
ContentOutputStream os = new ContentOutputStream(outputBuffer);
/** * Create synapse.response-source-buffer for GET and HEAD Http methods * @param method Http Method * @param request Source Request * @return OutputStream */ public OutputStream getOutputStream(String method,SourceRequest request){ OutputStream os=null; if (HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method)) { HttpContext context = request.getConnection().getContext(); ContentOutputBuffer outputBuffer = new SimpleOutputBuffer( sourceConfiguration.getIOBufferSize(), new HeapByteBufferAllocator()); context.setAttribute("synapse.response-source-buffer",outputBuffer); os = new ContentOutputStream(outputBuffer); } return os; }
/** * Wait for the SharedOutputBuffer to become available, write audio data to it. */ public void run() { this.logger = MaryUtils.getLogger(Thread.currentThread().getName()); // We must wait until produceContent() is called: while (out == null) { synchronized (mutex) { try { mutex.wait(); } catch (InterruptedException e) { } } } assert out != null; ContentOutputStream outStream = new ContentOutputStream(out); try { AudioSystem.write(audio, audioType, outStream); outStream.flush(); outStream.close(); logger.info("Finished writing output"); } catch (IOException ioe) { logger.info("Cannot write output, client seems to have disconnected. ", ioe); maryRequest.abort(); } } }
OutputStream out = new ContentOutputStream(outputBuffer); try { if (msgContext.isPropertyTrue(NhttpConstants.FORCE_HTTP_1_0)) {
/** * Wait for the SharedOutputBuffer to become available, write audio data to it. */ public void run() { this.logger = MaryUtils.getLogger(Thread.currentThread().getName()); // We must wait until produceContent() is called: while (out == null) { synchronized (mutex) { try { mutex.wait(); } catch (InterruptedException e) { } } } assert out != null; ContentOutputStream outStream = new ContentOutputStream(out); try { AudioSystem.write(audio, audioType, outStream); outStream.flush(); outStream.close(); logger.info("Finished writing output"); } catch (IOException ioe) { logger.info("Cannot write output, client seems to have disconnected. ", ioe); maryRequest.abort(); } } }
protected void sendResponse( final NHttpServerConnection conn, final HttpResponse response) throws IOException, HttpException { HttpContext context = conn.getContext(); ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE); ContentOutputBuffer buffer = connState.getOutbuffer(); this.httpProcessor.process(response, context); if (!canResponseHaveBody(connState.getRequest(), response)) { response.setEntity(null); } conn.submitResponse(response); // Update connection state connState.setOutputState(ServerConnState.RESPONSE_SENT); HttpEntity entity = response.getEntity(); if (entity != null) { OutputStream outstream = new ContentOutputStream(buffer); entity.writeTo(outstream); outstream.flush(); outstream.close(); } else { connState.resetOutput(); if (!this.connStrategy.keepAlive(response, context)) { conn.close(); } else { conn.requestInput(); } } }
= new NhttpSharedOutputBuffer(bufferSize, conn, allocator, socketTimeout); context.setAttribute(RESPONSE_SOURCE_BUFFER, outputBuffer); OutputStream os = new ContentOutputStream(outputBuffer);