           error: (xhr, errorType, error) ->
             done(error)
 
+    it 'can receive post data', (done) ->
+      handler = (request, callback) ->
+        uploadData = request.uploadData[0].bytes
+        callback(uploadData)
+      protocol.interceptBufferProtocol 'http', handler, (error) ->
+        return done(error) if error
+        $.ajax
+          url: "http://fake-host"
+          type: "POST"
+          data: postData
+          success: (data) ->
+            assert.equal data, $.param postData
+            done()
+          error: (xhr, errorType, error) ->
+            done(error)
+
+  describe 'protocol.interceptHttpProtocol', ->
+    it 'can send POST request', (done) ->
+      server = http.createServer (req, res) ->
+        body = ''
+        req.on 'data', (chunk) ->
+          body += chunk
+        req.on 'end', ->
+          res.end body
+        server.close()
+      server.listen 0, '127.0.0.1', ->
+        {port} = server.address()
+        url = "http://127.0.0.1:#{port}"
+        handler = (request, callback) ->
+          data =
+            url: url
+            method: 'POST'
+            uploadData:
+              contentType: 'application/x-www-form-urlencoded'
+              data: request.uploadData[0].bytes.toString()
+            session: null
+          callback(data)
+        protocol.interceptHttpProtocol 'http', handler, (error) ->
+          return done(error) if error
+          $.ajax
+            url: "http://fake-host"
+            type: "POST"
+            data: postData
+            success: (data) ->
+              assert.deepEqual qs.parse(data), postData
+              done()
+            error: (xhr, errorType, error) ->
+              done(error)
+
   describe 'protocol.uninterceptProtocol', ->
     it 'returns error when scheme does not exist', (done) ->
       protocol.uninterceptProtocol 'not-exist', (error) ->

          error: (xhr, errorType, error) ->
            done(error)

  describe 'protocol.interceptBufferProtocol', ->
    it 'can intercept http protocol', (done) ->
      handler = (request, callback) -> callback(new Buffer(text))

describe 'protocol module', ->
  protocolName = 'sp'
  text = 'valar morghulis'
  postData =
    name: 'post test'
    type: 'string'

  afterEach (done) ->
    protocol.unregisterProtocol protocolName, ->
