Class GassClientHandler

  • All Implemented Interfaces:
    java.lang.Runnable

    class GassClientHandler
    extends java.lang.Object
    implements java.lang.Runnable
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void debug​(java.lang.String msg)  
      private java.lang.String decodeUrlPath​(java.lang.String path)  
      private long fromHex​(java.lang.String s)
      Convert a String representing a hex number to a long.
      private java.io.OutputStream pickOutputStream​(java.lang.String path, java.lang.String str, java.io.OutputStream def)  
      private java.lang.String readLine​(java.io.InputStream in)
      Read a line of text from the given Stream and return it as a String.
      void run()
      Listen on the server socket for a client, start another thread to keep listening on the server socket, then deal with the client.
      private void transfer​(java.io.InputStream is, java.lang.String path, boolean append, java.io.OutputStream outs)
      Transfer from the given InputStream to a file, given its path.
      private void transfer​(java.io.OutputStream os, java.lang.String path)
      Transfer from a file, given its path, to the given OutputStream.
      private void write​(java.io.OutputStream out, java.lang.String msg)  
      private void writeln​(java.io.OutputStream out, java.lang.String msg)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GassClientHandler

        public GassClientHandler​(GassServer server,
                                 java.net.Socket socket)
    • Method Detail

      • write

        private void write​(java.io.OutputStream out,
                           java.lang.String msg)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • writeln

        private void writeln​(java.io.OutputStream out,
                             java.lang.String msg)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • run

        public void run()
        Listen on the server socket for a client, start another thread to keep listening on the server socket, then deal with the client.
        Specified by:
        run in interface java.lang.Runnable
      • decodeUrlPath

        private java.lang.String decodeUrlPath​(java.lang.String path)
      • transfer

        private void transfer​(java.io.OutputStream os,
                              java.lang.String path)
                       throws java.io.IOException
        Transfer from a file, given its path, to the given OutputStream. The BufferedWriter points to the same stream but is used to write HTTP header information.
        Throws:
        java.io.IOException
      • pickOutputStream

        private java.io.OutputStream pickOutputStream​(java.lang.String path,
                                                      java.lang.String str,
                                                      java.io.OutputStream def)
      • transfer

        private void transfer​(java.io.InputStream is,
                              java.lang.String path,
                              boolean append,
                              java.io.OutputStream outs)
                       throws java.io.IOException
        Transfer from the given InputStream to a file, given its path. The Reader points to the same stream but is used to read the HTTP header information.
        Throws:
        java.io.IOException
      • readLine

        private java.lang.String readLine​(java.io.InputStream in)
                                   throws java.io.IOException
        Read a line of text from the given Stream and return it as a String. Assumes lines end in CRLF.
        Throws:
        java.io.IOException
      • fromHex

        private long fromHex​(java.lang.String s)
        Convert a String representing a hex number to a long.
      • debug

        private void debug​(java.lang.String msg)