String uriString = request.getRequestLine().getUri(); Uri uri = Uri.parse(uriString); if (uri != null) { if (uri.toString().contains("mypic.jpg")) { HttpEntity entity = new EntityTemplate(new ContentProducer() { public void writeTo(final OutputStream outstream) throws IOException { InputStream is = context.getResources() .openRawResource(R.raw.mypic); copyStream(is, outstream); } }); response.setHeader("Content-Type", "image/jpg"); response.setEntity(entity); } else{ HttpEntity entity = new EntityTemplate(new ContentProducer() { public void writeTo(final OutputStream outstream) throws IOException { InputStream is = context.getResources().openRawResource( R.raw.home); copyStream(is, outstream); } }); response.setHeader("Content-Type", "text/html"); response.setEntity(entity); } }
@Override public InputStream getContent() throws IOException { final ByteArrayOutputStream buf = new ByteArrayOutputStream(); writeTo(buf); return new ByteArrayInputStream(buf.toByteArray()); }
entity.setChunked(context.getProperty(CHUNKED_ENCODING).asBoolean());
/** Create an HttpEntity for the graph */ protected HttpEntity graphToHttpEntity(Graph graph, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, graph, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
/** Create an HttpEntity for the dataset */ protected HttpEntity datasetToHttpEntity(DatasetGraph dataset, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, dataset, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
/** Create an HttpEntity for the dataset */ protected HttpEntity datasetToHttpEntity(DatasetGraph dataset, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, dataset, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
@Override public void saveFile(String path, RepeatableContentProducer repeatableContentProducer) { saveFile(path, new EntityTemplate(toApacheContentProducer(repeatableContentProducer))); }
@Override public InputStream getContent() throws IOException { final ByteArrayOutputStream buf = new ByteArrayOutputStream(); writeTo(buf); return new ByteArrayInputStream(buf.toByteArray()); }
entity.setChunked(context.getProperty(CHUNKED_ENCODING).asBoolean());
/** Create an HttpEntity for the graph */ protected HttpEntity graphToHttpEntity(Graph graph, RDFFormat syntax) { EntityTemplate entity = new EntityTemplate((out)->RDFDataMgr.write(out, graph, syntax)); String ct = syntax.getLang().getContentType().getContentType(); entity.setContentType(ct); return entity; }
@Override public void saveFile(String path, RepeatableContentProducer repeatableContentProducer) { saveFile(path, new EntityTemplate(toApacheContentProducer(repeatableContentProducer))); }
@Override public InputStream getContent() throws IOException { final ByteArrayOutputStream buf = new ByteArrayOutputStream(); writeTo(buf); return new ByteArrayInputStream(buf.toByteArray()); }
/** Create an HttpEntity for the graph */ protected HttpEntity graphToHttpEntity(final Graph graph) { final RDFFormat syntax = getOutboundSyntax() ; ContentProducer producer = new ContentProducer() { @Override public void writeTo(OutputStream out) { RDFDataMgr.write(out, graph, syntax) ; } } ; EntityTemplate entity = new EntityTemplate(producer) ; String ct = syntax.getLang().getContentType().getContentType() ; entity.setContentType(ct) ; return entity ; } }
post.setEntity(new EntityTemplate(cp));
@Override public InputStream getContent() throws IOException { final ByteArrayOutputStream buf = new ByteArrayOutputStream(); writeTo(buf); return new ByteArrayInputStream(buf.toByteArray()); }
/** Create an HttpEntity for the graph */ protected HttpEntity graphToHttpEntity(final Graph graph) { final RDFFormat syntax = getOutboundSyntax() ; ContentProducer producer = new ContentProducer() { @Override public void writeTo(OutputStream out) throws IOException { RDFDataMgr.write(out, graph, syntax) ; } } ; EntityTemplate entity = new EntityTemplate(producer) ; String ct = syntax.getLang().getContentType().getContentType() ; entity.setContentType(ct) ; return entity ; } }
post.setEntity(new EntityTemplate(cp));
public InputStream getContent() throws IOException { final ByteArrayOutputStream buf = new ByteArrayOutputStream(); writeTo(buf); return new ByteArrayInputStream(buf.toByteArray()); }
/** Create an HttpEntity for the graph */ protected static HttpEntity graphToHttpEntity(final Graph graph) { final RDFFormat syntax = RDFFormat.TURTLE_BLOCKS ; ContentProducer producer = new ContentProducer() { @Override public void writeTo(OutputStream out) { RDFDataMgr.write(out, graph, syntax) ; } } ; EntityTemplate entity = new EntityTemplate(producer) ; ContentType ct = syntax.getLang().getContentType() ; entity.setContentType(ct.getContentType()) ; return entity ; }
put.setEntity(new EntityTemplate(cp));