     urls = url.parse req.url
     @query = querystring.parse urls.query
     @query.raw = urls.query
-
     # response buffer
     @_buffer.removeAllListeners 'error'
     @_buffer.on 'error', (err) => @_error? err
-
     # default content
+    @writeHead 200, "Content-Type": "text/plain;charset=utf-8"
     return @render() if !@query.raw or @query.raw.length < 1
-
     # application content
-    @writeHead 200, "Content-Type": "text/javascript;charset=utf-8"
     return @end application.script() if @query.raw is 'script'
     # post data
-    data = ''
-    req.addListener 'data', (chunk) -> data += chunk
-    req.addListener 'end', =>
-      @_form = querystring.parse data
-      @_form.raw = data
+    raw = ''
+    req.on 'data', (chunk) -> raw += chunk
+    req.on 'end', =>
+      @data = @parse raw if raw.length > 0
       switch @query._id
-         when 'EVENT' then @_event()
-
-  # Application's event
-  _event: ->
-    type = @query.type
-    index = type.length
-    index = 3 if (type.indexOf('key') is 0) or (type.indexOf('dbl') is 0)
-    index = 5 if type.indexOf('mouse') is 0
-    methodName = @query.id + type.substr(0, index).ucfirst() + type.substr(index).ucfirst()
-    return @end() if typeof @[methodName] isnt 'function'
-    @query = null
-    @[methodName]()
+        when 'event'
+          selector = @query.selector
+          @[selector]() if typeof @[selector] is 'function'
+          @end()

      @_finish = null
      @_error? err
    # application's event callback
    @_sync = false
    @_callback = ''

  # End buffer
  end: ->
    if @_callback.length > 0
      @_buffer?.write "
        window.app._sync = #{@_sync.toString()};
        window.app._callback = function() {
          #{@_callback}
        };
      "
    @_buffer?.end.apply @_buffer, arguments

  # Write chunk to buffer
  write: -> @_buffer?.write.apply @_buffer, arguments

  # Write status and headers
  writeHead: -> @_buffer?.writeHead.apply @_buffer, arguments

  # Receive stream
  receive: (stream, encoding = 'utf8') ->
    return unless stream instanceof Readable
    stream.setEncoding = encoding if typeof encoding is 'string'
    stream.pipe @_buffer if @_buffer

{Readable} = require 'stream'
querystring = require 'querystring'

# function -> script
Function::script = (argv) ->
  env = ''
