MCPcopy Index your code
hub / github.com/benfry/processing4 / printHeaders

Method printHeaders

app/src/processing/app/WebServer.java:215–254  ·  view source on GitHub ↗
(PrintStream ps, String path, ZipEntry entry)

Source from the content-addressed store, hash-verified

213 }
214
215 boolean printHeaders(PrintStream ps, String path, ZipEntry entry) throws IOException {
216 int status;
217 if (entry == null) {
218 status = HTTP_NOT_FOUND;
219 ps.print("HTTP/1.0 " + HTTP_NOT_FOUND + " Not Found");
220 } else {
221 status = HTTP_OK;
222 ps.print("HTTP/1.0 " + HTTP_OK + " OK");
223 }
224 ps.write(EOL);
225 Messages.log("From " + socket.getInetAddress().getHostAddress() + ": GET " + path + " --> " + status);
226
227 ps.print("Server: Processing Reference Server");
228 ps.write(EOL);
229 ps.print("Date: " + new Date());
230 ps.write(EOL);
231
232 if (entry != null) {
233 if (!entry.isDirectory()) {
234 ps.print("Content-length: " + entry.getSize());
235 ps.write(EOL);
236 ps.print("Last Modified: " + new Date(entry.getTime()));
237 ps.write(EOL);
238 String name = entry.getName();
239 int ind = name.lastIndexOf('.');
240 String contentType = "application/x-unknown-content-type";
241 if (ind > 0) {
242 contentType = contentTypes.getOrDefault(name.substring(ind), contentType);
243 }
244 ps.print("Content-type: " + contentType);
245 } else {
246 ps.print("Content-type: text/html");
247 }
248 ps.write(EOL);
249 }
250 ps.write(EOL); // adding another newline here [fry]
251
252 // indicates whether to send a file on return
253 return status == HTTP_OK;
254 }
255
256 void send404(PrintStream ps) throws IOException {
257 ps.write(EOL);

Callers 1

handleClientMethod · 0.95

Calls 6

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

Tested by

no test coverage detected