!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/ai_detect/Flower_Classification_Tensorflow.js/train/node_modules/needle/test/   drwxr-xr-x
Free 13.16 GB of 57.97 GB (22.71%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     request_stream_spec.js (5.22 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
var fs     = require('fs'),
    needle = require('..'),
    stream = require('stream'),
    http   = require('http'),
    should = require('should'),
    sinon  = require('sinon');

var port   = 2233;

describe('request stream length', function() {

  var server, writable;

  function createServer() {
    return http.createServer(function(req, res) {

      req.on('data', function(chunk) {
        // console.log(chunk.length);
      })

      req.on('end', function() {
        res.writeHeader(200, { 'Content-Type': 'application/json'})
        res.end(JSON.stringify({ headers: req.headers }))
      })

    })
  }

  before(function(done) {
    server = createServer();
    server.listen(port, done)
  })

  beforeEach(function() {
    writable = new stream.Readable();
    writable._read = function() {
      this.push('hello world');
      this.push(null);
    }
  })

  after(function(done) {
    server.close(done)
  })

  function send_request(opts, cb) {
    needle.post('http://localhost:' + port, writable, opts, function(err, resp) {
      cb(err, resp)
    })
  }

  describe('no stream_length set', function() {

    it('doesnt set Content-Length header', function(done) {
      send_request({}, function(err, resp) {
        should.not.exist(resp.body.headers['content-length']);
        done()
      })
    })

    it('doesnt work if Transfer-Encoding is set to a blank string', function(done) {
      send_request({ headers: { 'Transfer-Encoding': '' }}, function(err, resp) {
        err.code.should.eql('ECONNRESET');
        done()
      })
    })

    it('works if Transfer-Encoding is not set', function(done) {
      send_request({}, function(err, resp) {
        should.not.exist(err);
        resp.statusCode.should.eql(200);
        done()
      })
    })

  })

  describe('stream_length set to invalid value', function() {

    it('sets Content-Length header to that value', function(done) {
      send_request({ stream_length: 5 }, function(err, resp) {
        should.exist(err);
        err.code.should.eql('ECONNRESET');
        done()
      })
    })

    it('doesnt work if Transfer-Encoding is set to a blank string', function(done) {
      send_request({ stream_length: 5, headers: { 'Transfer-Encoding': '' }}, function(err, resp) {
        err.code.should.eql('ECONNRESET');
        done()
      })
    })

    it('doesnt work if Transfer-Encoding is not set', function(done) {
      send_request({ stream_length: 5 }, function(err, resp) {
        err.code.should.eql('ECONNRESET');
        done()
      })
    })

  })

  describe('stream_length is set to valid value', function() {

    it('sets Content-Length header to that value', function(done) {
      send_request({ stream_length: 11 }, function(err, resp) {
        resp.body.headers['content-length'].should.eql('11');
        done()
      })
    })

    it('works if Transfer-Encoding is set to a blank string', function(done) {
      send_request({ stream_length: 11, headers: { 'Transfer-Encoding': '' }}, function(err, resp) {
        should.not.exist(err);
        resp.statusCode.should.eql(200);
        done()
      })
    })

    it('works if Transfer-Encoding is not set', function(done) {
      send_request({ stream_length: 11 }, function(err, resp) {
        should.not.exist(err);
        resp.statusCode.should.eql(200);
        done()
      })
    })

  })


  describe('stream_length set to 0', function() {

    describe('stream with path', function() {

      var stub;

      beforeEach(function() {
        writable.path = '/foo/bar';
        stub = sinon.stub(fs, 'stat', function(path, cb) {
          cb(null, { size: 11 })
        })
      })

      afterEach(function() {
        stub.restore();
      })

      it('sets Content-Length header to streams length', function(done) {
        send_request({ stream_length: 0 }, function(err, resp) {
          resp.body.headers['content-length'].should.eql('11');
          done()
        })
      })

      it('works if Transfer-Encoding is set to a blank string', function(done) {
        send_request({ stream_length: 0, headers: { 'Transfer-Encoding': '' }}, function(err, resp) {
          should.not.exist(err);
          resp.statusCode.should.eql(200);
          done()
        })
      })

      it('works if Transfer-Encoding is not set', function(done) {
        send_request({ stream_length: 0 }, function(err, resp) {
          should.not.exist(err);
          resp.statusCode.should.eql(200);
          done()
        })
      })

    })

    describe('stream without path', function() {
      it('does not set Content-Length header', function(done) {
        send_request({ stream_length: 0 }, function(err, resp) {
          should.not.exist(resp.body.headers['content-length']);
          done()
        })
      })

      it('doesnt work if Transfer-Encoding is set to a blank string', function(done) {
        send_request({ stream_length: 0, headers: { 'Transfer-Encoding': '' }}, function(err, resp) {
          err.code.should.eql('ECONNRESET');
          done()
        })
      })

      it('works if Transfer-Encoding is not set', function(done) {
        send_request({ stream_length: 0 }, function(err, resp) {
          should.not.exist(err);
          resp.statusCode.should.eql(200);
          done()
        })
      })

    })


  })

})

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.005 ]--