- From: Anselm Baird_Smith <abaird@www43.inria.fr>
- Date: Tue, 12 Nov 1996 09:24:25 +0100 (MET)
- To: Dave Makower <davemak@pencom.com>
- Cc: www-jigsaw@w3.org
Dave Makower writes: > > Any suggestions? Some, yes, see the code > //------------------- StreamResource.java ------------------- > > public Reply get(Request request) { > Reply reply = request.makeReply(HTTP.OK); This should rather be (new since alpha3): Reply reply = createDefaultReply(request, HTTP.OK); > InputStream content = null; > > > > // Present the content > content = makeStream(); > > // Put the content in the Reply object > if (content != null) { You probably also want to set the content type, which would otherwise default to tex/plain: reply.setContentType(MimeType.TEXT_HTML); > reply.setStream(content); > } else { > reply.setStatus(HTTP.NO_CONTENT); That's your bug ! I don't understand why you use NO_CONTENT here, but still provide a content ! If you want to provide a content use some other error code... > HtmlGenerator gen = new HtmlGenerator("Not Found"); > gen.append("<H1 ALIGN=\"CENTER\">\n"); > gen.append("404 - Not Found\n"); > gen.append("</H1>\n"); > gen.append("<HR>\n"); > gen.append("The resource" + getURL() + "has no content.\n"); > gen.append("<P>"); > > if (request != null) { > gen.append("Referring URL: "); > gen.append("<A HREF=\"" + request.getReferer() + "\">"); > gen.append(request.getReferer()); > gen.append("</A>\n"); > gen.append("<P>"); > } > > gen.close(); > reply.setStream(gen); Last two lines can be sort-cuted to reply.setStream(gen), since this will close the HtmlGenerator for you.
Received on Tuesday, 12 November 1996 03:24:40 UTC