MCPcopy Create free account
hub / github.com/beanshell/beanshell / serveFile

Method serveFile

src/bsh/util/Httpd.java:134–167  ·  view source on GitHub ↗
(String file)

Source from the content-addressed store, hash-verified

132 }
133
134 private void serveFile(String file)
135 throws FileNotFoundException, IOException
136 {
137 // Do some mappings
138 if ( file.equals("/") )
139 file = "/remote/remote.html";
140
141 if ( file.startsWith("/remote/") )
142 file = "/bsh/util/lib/" + file.substring(8);
143
144 /*
145 if(file.startsWith("/"))
146 file = file.substring(1);
147 if(file.endsWith("/") || file.equals(""))
148 file = file + "index.html";
149
150 if(!fileAccessOK(file))
151 {
152 error(403, "Forbidden");
153 return;
154 }
155 */
156
157 // don't send java packages over... (e.g. swing)
158 if ( file.startsWith("/java" ) )
159 error(404, "Object Not Found");
160 else
161 try {
162 System.out.println("sending file: "+file);
163 sendFileData(file);
164 } catch(FileNotFoundException e) {
165 error(404, "Object Not Found");
166 }
167 }
168
169 private void sendFileData(String file)
170 throws IOException, FileNotFoundException

Callers 1

runMethod · 0.95

Calls 4

errorMethod · 0.95
sendFileDataMethod · 0.95
printlnMethod · 0.65
equalsMethod · 0.45

Tested by

no test coverage detected