MCPcopy Index your code
hub / github.com/processing/processing / printHeaders

Method printHeaders

app/src/processing/app/WebServer.java:341–387  ·  view source on GitHub ↗
(ZipEntry targ, PrintStream ps)

Source from the content-addressed store, hash-verified

339
340
341 boolean printHeaders(ZipEntry targ, PrintStream ps) throws IOException {
342 boolean ret = false;
343 int rCode = 0;
344 if (targ == null) {
345 rCode = HTTP_NOT_FOUND;
346 ps.print("HTTP/1.0 " + HTTP_NOT_FOUND + " Not Found");
347 ps.write(EOL);
348 ret = false;
349 } else {
350 rCode = HTTP_OK;
351 ps.print("HTTP/1.0 " + HTTP_OK + " OK");
352 ps.write(EOL);
353 ret = true;
354 }
355 if (targ != null) {
356 WebServer.log("From " +s.getInetAddress().getHostAddress()+": GET " + targ.getName()+" --> "+rCode);
357 }
358 ps.print("Server: Processing Documentation Server");
359 ps.write(EOL);
360 ps.print("Date: " + (new Date()));
361 ps.write(EOL);
362 if (ret) {
363 if (!targ.isDirectory()) {
364 ps.print("Content-length: " + targ.getSize());
365 ps.write(EOL);
366 ps.print("Last Modified: " + new Date(targ.getTime()));
367 ps.write(EOL);
368 String name = targ.getName();
369 int ind = name.lastIndexOf('.');
370 String ct = null;
371 if (ind > 0) {
372 ct = map.get(name.substring(ind));
373 }
374 if (ct == null) {
375 //System.err.println("unknown content type " + name.substring(ind));
376 ct = "application/x-unknown-content-type";
377 }
378 ps.print("Content-type: " + ct);
379 ps.write(EOL);
380 } else {
381 ps.print("Content-type: text/html");
382 ps.write(EOL);
383 }
384 }
385 ps.write(EOL); // adding another newline here [fry]
386 return ret;
387 }
388
389
390 boolean printHeaders(File targ, PrintStream ps) throws IOException {

Callers 1

handleClientMethod · 0.95

Calls 7

logMethod · 0.95
getSizeMethod · 0.80
getTimeMethod · 0.80
printMethod · 0.65
writeMethod · 0.65
getMethod · 0.65
getNameMethod · 0.45

Tested by

no test coverage detected