RSS

(root)/fsp/fsproxy : 28

hsn at sendmail
2009-10-29 22:38:22
Revision ID: hsn@sendmail.cz-20091029223822-0mrgil5au0cd4sfm
Detect if jfsplib is installed

collapse all collapse all

added added

removed removed

5
    TODO file removed, issues moved to mantis bug tracker
5
    TODO file removed, issues moved to mantis bug tracker
6
    Distributed jar file is autostartable
6
    Distributed jar file is autostartable
7
    return error to client if Range: header parsing failed
7
    return error to client if Range: header parsing failed
 
 
8
    detect on startup if jfsplib 1.0rc7 or greater is installed
8
0.7
9
0.7
9
        Nice directory listings with file size and last modification time!
10
        Nice directory listings with file size and last modification time!
10
        Added tagline to generated error messages
11
        Added tagline to generated error messages
6
harmless for any loss or damage resulting from the installation or
6
harmless for any loss or damage resulting from the installation or
7
use of this software.
7
use of this software.
8
 
8
 
9
                     This is a free software.  Be creative. 
9
                     This is a free software.  Be creative.
10
                    Let me know of any bugs and suggestions.
10
                    Let me know of any bugs and suggestions.
11
*/
11
*/
12
import java.io.*;
12
import java.io.*;
13
import java.util.StringTokenizer;
13
import java.util.StringTokenizer;
14
import java.util.Date;
14
import java.util.Date;
15
 
15
 
 
 
16
import net.fsp.FSPprotection;
 
 
17
 
16
/* stand-alone version of fsp -> http proxy server */
18
/* stand-alone version of fsp -> http proxy server */
17
public class fspproxy
19
public class fspproxy
18
{
20
{
20
    public static int client_timeout;
22
    public static int client_timeout;
21
    public static boolean trace_url;
23
    public static boolean trace_url;
22
    public static String defaultype="application/octet-stream";
24
    public static String defaultype="application/octet-stream";
23
   
25
 
24
    public static void print_usage()
26
    public static void print_usage()
25
    {
27
    {
26
        System.out.println("java fspproxy [port number] [mime types file]");
28
        System.out.println("java fspproxy [port number] [mime types file]");
27
        System.exit(1);
29
        System.exit(1);
28
    }
30
    }
29
        
31
 
30
    public static void main(String argv[])
32
    public static void main(String argv[])
31
    {
33
    {
 
 
34
    /* check if jfsplib is installed */
 
 
35
    try
 
 
36
    {
 
 
37
        Class.forName("net.fsp.FSPprotection");
 
 
38
    }
 
 
39
    catch (ClassNotFoundException z)
 
 
40
    {
 
 
41
        System.out.println("jfsplib not found in classpath or its old version. You need at least 1.0rc7 version of jfsplib.");
 
 
42
        System.exit(2);
 
 
43
    }
32
        client_timeout=500000;
44
        client_timeout=500000;
33
        trace_url=true;
45
        trace_url=true;
34
        int port=9090;
46
        int port=9090;
35
        if(argv.length>0)
47
        if(argv.length>0)
36
        {   
48
        {
37
            try
49
            try
38
            { 
50
            {
39
               port=Integer.valueOf(argv[0]).intValue();
51
               port=Integer.valueOf(argv[0]).intValue();
40
            }
52
            }
41
            catch (Exception z)
53
            catch (Exception z)
47
                System.out.println(new Date()+" Using user defined MIME types table from "+argv[1]);
59
                System.out.println(new Date()+" Using user defined MIME types table from "+argv[1]);
48
                loadMimeTypes(argv[1]);
60
                loadMimeTypes(argv[1]);
49
            }
61
            }
50
        }    
62
        }
51
        new fsploop(port,null).run();
63
        new fsploop(port,null).run();
52
    }
64
    }
53
 
65
 
98
      seven=proto.length()+3; /* '://' */
110
      seven=proto.length()+3; /* '://' */
99
 
111
 
100
      }
112
      }
101
      else 
113
      else
102
      {
114
      {
103
          seven=url.indexOf("://");
115
          seven=url.indexOf("://");
104
          res[4]=url.substring(0,seven);
116
          res[4]=url.substring(0,seven);
201
            if(mimetype.startsWith("#")) continue;
213
            if(mimetype.startsWith("#")) continue;
202
            while(true)
214
            while(true)
203
            {
215
            {
204
                
216
 
205
                if(!st.hasMoreTokens()) break;
217
                if(!st.hasMoreTokens()) break;
206
                ext=st.nextToken();
218
                ext=st.nextToken();
207
                updateGuessTable(mimetype,ext);
219
                updateGuessTable(mimetype,ext);
255
             ".java","text/plain",
267
             ".java","text/plain",
256
             ".class","application/java-vm",
268
             ".class","application/java-vm",
257
             ".jar","application/java-archive",
269
             ".jar","application/java-archive",
258
        
270
 
259
             // images
271
             // images
260
             ".gif","image/gif",
272
             ".gif","image/gif",
261
             ".ief","image/ief",
273
             ".ief","image/ief",
275
             ".xbm","image/x-xbitmap",
287
             ".xbm","image/x-xbitmap",
276
             ".xpm","image/x-xpixmap",
288
             ".xpm","image/x-xpixmap",
277
             ".xwd","image/x-xwindowdump",
289
             ".xwd","image/x-xwindowdump",
278
        
290
 
279
             // plain text
291
             // plain text
280
             ".txt","text/plain",
292
             ".txt","text/plain",
281
             ".text","text/plain",
293
             ".text","text/plain",
304
             ".php4",  "text/html",
316
             ".php4",  "text/html",
305
             ".php3p", "text/html",
317
             ".php3p", "text/html",
306
             ".php4p", "text/html",
318
             ".php4p", "text/html",
307
        
319
 
308
             ".texi","application/x-texinfo",
320
             ".texi","application/x-texinfo",
309
             ".texinfo","application/x-texinfo",
321
             ".texinfo","application/x-texinfo",
310
 
322
 
312
             ".vrm","x-world/x-vrml",
324
             ".vrm","x-world/x-vrml",
313
             ".vrml","x-world/x-vrml",
325
             ".vrml","x-world/x-vrml",
314
             ".wrl" ,"x-world/x-vrml",
326
             ".wrl" ,"x-world/x-vrml",
315
        
327
 
316
             // formated text
328
             // formated text
317
             ".rtx","text/richtext",
329
             ".rtx","text/richtext",
318
             ".pdf","application/pdf",
330
             ".pdf","application/pdf",
354
             ".sit","application/x-stuffit",
366
             ".sit","application/x-stuffit",
355
             ".sv4cpio","application/x-sv4cpio",
367
             ".sv4cpio","application/x-sv4cpio",
356
             ".sv4crc","application/x-sv4crc",
368
             ".sv4crc","application/x-sv4crc",
357
        
369
 
358
             //audio
370
             //audio
359
             ".au","audio/basic",
371
             ".au","audio/basic",
360
             ".snd","audio/basic",
372
             ".snd","audio/basic",
425
             ".cdf","application/x-netcdf",
437
             ".cdf","application/x-netcdf",
426
             ".pac","application/x-ns-proxy-autoconfig",
438
             ".pac","application/x-ns-proxy-autoconfig",
427
             ".swf","application/x-shockwave-flash",
439
             ".swf","application/x-shockwave-flash",
428
             ".swfl","application/x-shockwave-flash",   
440
             ".swfl","application/x-shockwave-flash",
429
             ".ustar","application/x-ustar",
441
             ".ustar","application/x-ustar",
430
             ".src","application/x-wais-source",
442
             ".src","application/x-wais-source",
431
             ".torrent","application/x-bittorrent",
443
             ".torrent","application/x-bittorrent",
439
             ".xls","application/excel",
451
             ".xls","application/excel",
440
             ".dot","application/msword",
452
             ".dot","application/msword",
441
             ".ppt","application/powerpoint",
453
             ".ppt","application/powerpoint",
442
        
454
 
443
             //binary files
455
             //binary files
444
             ".bin","application/octet-stream",
456
             ".bin","application/octet-stream",
445
 
457
 

Loggerhead is a web-based interface for Bazaar branches