0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
Commit Graph

42 Commits

Author SHA1 Message Date
Sakthipriyan Vairamani
9afee6785e http: Check this.connection before using it
Refer: https://github.com/joyent/node/pull/25670

PR-URL: https://github.com/nodejs/io.js/pull/2172
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-07-22 21:44:59 +05:30
Sakthipriyan Vairamani
9cd44bb2b6 util: prepend '(node) ' to deprecation messages
Changes included in this commit are

   1. Making the deprecation messages consistent. The messages will be in
      the following format

           x is deprecated. Use y instead.

      If there is no alternative for `x`, then the ` Use y instead.` part
      will not be there in the message.

   2. All the internal deprecation messages are printed with the prefix
      `(node) `, except when the `--trace-deprecation` flag is set.

Fixes: https://github.com/nodejs/io.js/issues/1883
PR-URL: https://github.com/nodejs/io.js/pull/1892
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-07-03 16:32:29 +02:00
Roman Reiss
b5b8ff117c lib: don't use global Buffer
Port of https://github.com/joyent/node/pull/8603

The race condition present in the original PR didn't occur, so no
workaround was needed.

PR-URL: https://github.com/nodejs/io.js/pull/1794
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-06-11 20:24:44 +02:00
Vladimir Kurchatkin
2c686fd3ce http: flush stored header
`flushHeaders` should work for header written
with `writeHead`.

PR-URL: https://github.com/nodejs/io.js/pull/1695
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-05-29 16:19:12 +03:00
Brian White
1eec5f091a http: simplify code and remove unused properties
PR-URL: https://github.com/nodejs/io.js/pull/1572
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-05-25 01:07:22 -04:00
Evan Lucas
d4726cde57 http,net,tls: return this from setTimeout methods
Modifies the setTimeout methods for the following prototypes:

- http.ClientRequest
- http.IncomingMessage
- http.OutgoingMessage
- http.Server
- https.Server
- net.Socket
- tls.TLSSocket

Previously, the above functions returned undefined. They now return
`this`. This is useful for chaining function calls.

PR-URL: https://github.com/nodejs/io.js/pull/1699
Reviewed-By: Roman Reiss <me@silverwind.io>
2015-05-16 07:17:41 +02:00
Yosuke Furukawa
19ffb5cf1c lib: fix eslint styles
PR-URL: https://github.com/iojs/io.js/pull/1539
Fixes: https://github.com/iojs/io.js/issues/1253
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2015-05-09 12:10:02 +09:00
Trevor Norris
10e31ba56c node: allow multiple arguments passed to nextTick
PR-URL: https://github.com/iojs/io.js/pull/1077
Reviewed-by: Colin Ihrig <cjihrig@gmail.com>
2015-04-15 17:02:21 -06:00
Yosuke Furukawa
b2e00e38dc http: add flushHeaders and deprecate flush
PR-URL: https://github.com/iojs/io.js/pull/1156
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Christian Tellnes <christian@tellnes.no>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-03-17 00:54:11 +01:00
Christian Tellnes
4874182065 http: send Content-Length when possible
This changes the behavior for http to send send a Content-Length header
instead of using chunked encoding when we know the size of the body when
sending the headers.

Fixes: https://github.com/iojs/io.js/issues/1044
PR-URL: https://github.com/iojs/io.js/pull/1062
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Brian White <mscdex@mscdex.net>
2015-03-05 22:17:35 +01:00
Brendan Ashworth
08133f45c7 http: optimize outgoing requests
This commit does some small optimization changes on
`lib/_http_outgoing.js`. These include switching from `while` loops to
`for` loops, moving away from `util` to `typeof` checks, and removing
dead code. It also includes variable caches to avoid lookups and
generic style changes. All in all, much faster execution.

It gets an across the board increase in req/sec on the benchmarks,
from my experience about a 10% increase.

PR-URL: https://github.com/iojs/io.js/pull/605
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Nicu Micleușanu <micnic90@gmail.com>
Reviewed-By: Christian Vaagland Tellnes <christian@tellnes.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2015-03-03 21:53:58 -08:00
Christian Tellnes
675cffb33e http: don't confuse automatic headers for others
If you set a custom http header which includes eg. the string `Date`,
then http will not automatically send the `Date` header.

This is also true for other automatic http headers.

PR-URL: https://github.com/iojs/io.js/pull/828
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-02-27 21:47:39 -08:00
cjihrig
6ac8bdc0ab lib: reduce util.is*() usage
Many of the util.is*() methods used to check data types
simply compare against a single value or the result of
typeof. This commit replaces calls to these methods with
equivalent checks. This commit does not touch calls to the
more complex methods (isRegExp(), isDate(), etc.).

Fixes: https://github.com/iojs/io.js/issues/607
PR-URL: https://github.com/iojs/io.js/pull/647
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-31 23:47:29 -05:00
Qasim Zaidi
cf3e908b70 http: more descriptive setHeader errors
PR-URL: https://github.com/iojs/io.js/pull/480
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2015-01-29 16:58:36 -08:00
cjihrig
804e7aa9ab lib: use const to define constants
This commit replaces a number of var statements throughout
the lib code with const statements.

PR-URL: https://github.com/iojs/io.js/pull/541
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-21 16:21:31 -05:00
isaacs
3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00
Ben Noordhuis
21130c7d6f lib: turn on strict mode
Turn on strict mode for the files in the lib/ directory.  It helps
catch bugs and can have a positive effect on performance.

PR-URL: https://github.com/node-forward/node/pull/64
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-11-22 17:23:30 +01:00
Trevor Norris
979d0ca874 http: cleanup setHeader()
Several fields on OutgoingMessage were set after instantiation. These
have been included in the constructor to prevent mutation of the object
map after instantiation.

"name" is now explicitly checked to be a string. Where before if a
non-string was passed the following cryptic error was thrown:

    _http_outgoing.js:334
      var key = name.toLowerCase();
                     ^
    TypeError: undefined is not a function

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-29 12:32:42 -07:00
Julien Gilli
64d6de9f34 http: write() after end() emits an error.
When calling write() after end() has been called on an OutgoingMessage,
an error is emitted and the write's callback is called with an instance
of Error.

Fix #7477.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-23 11:54:26 +04:00
Timothy J Fontaine
7ca5af87a0 Merge remote-tracking branch 'upstream/v0.10' into v0.12
Conflicts:
	ChangeLog
	deps/v8/src/hydrogen.cc
	lib/http.js
	lib/querystring.js
	src/node_crypto.cc
	src/node_version.h
	test/simple/test-querystring.js
2014-09-16 17:48:09 -07:00
Ben Noordhuis
bd24ab2bd7 http: add request.flush() method
Forcibly flushes the request headers.  You need this with long-lived
HTTP connections where the first data isn't written until the connection
has been established (think: tunneling requests over HTTP CONNECT.)

Fixes #7296.

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-24 10:43:51 +04:00
Yuki KAN
006d42786e lib: use triple equals
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-04-02 02:12:18 -07:00
Trevor Norris
2eddd74112 http: use writev on chunked encoding
Now will process all write() that were done on a single tick in a single
writev().
2014-01-09 15:07:14 -08:00
James Halliday
5555318bf3 http: removed headers stay removed
This allows automatically-inserted headers to be removed permanently by
calling OutgoingMessage.removeHeader() on them, as if they were normal
headers.
2013-08-19 16:05:44 -07:00
Brian White
6d842897c5 lib: remove unused variables and functions 2013-08-15 17:19:17 -07:00
isaacs
1f9f863494 http: Prefer 'binary' over 'ascii'
It's faster, because it doesn't have to check that each char is in the
ASCII plane.
2013-08-15 15:05:41 -07:00
isaacs
7c9b607048 http: Consistent 'finish' event semantics
In other Writable streams, the 'finish' event means that all of the data
was written, and flushed to the underlying system.

The 'prefinish' event means that end() was called, and all of the data
was processed, but not necessarily completely flushed.

This change brings the http OutgoingMessage classes more in sync with
the other Writable classes throughout Node.

Unfortunately, this change highlights an issue with http
IncomingMessages, where the _dump() method will not actually pull the
data off the wire.  This is a minor issue that is typically only
relevant in test cases, and will be addressed in the next commit.
2013-08-15 15:05:41 -07:00
isaacs
e3157972e1 http: make OutgoingMessage._flush inline-able 2013-08-15 15:05:41 -07:00
isaacs
da93d6adfb http: Add write()/end() callbacks 2013-08-15 15:05:41 -07:00
isaacs
ce3d18412c http: Write hex/base64 chunks properly
This removes a dubious performance "optimization" where strings body
chunks were concatenated to one another (and to the headers) without any
regard for their encoding.
2013-08-15 15:05:40 -07:00
isaacs
22c68fdc1d src: Replace macros with util functions 2013-08-01 15:08:01 -07:00
Ben Noordhuis
0330bdf519 lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
2013-07-24 21:49:35 +02:00
isaacs
831de7cbb9 http: Use OOP for OutgoingMessage._finish
Sniffing instanceof a child class in the parent class's method
is Doing It Wrong.
2013-07-09 22:31:11 -07:00
Peter Rust
82ff891e22 http: use an unref'd timer to fix delay in exit
There was previously up to a second exit delay when exiting node
right after an http request/response, due to the utcDate() function
doing a setTimeout to update the cached date/time.

Fixing this should increase the performance of our http tests.
2013-07-07 21:12:07 -07:00
isaacs
ba048e72b0 Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	configure
	deps/uv/ChangeLog
	deps/uv/src/unix/darwin.c
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/v8/src/isolate.cc
	deps/v8/src/version.cc
	lib/http.js
	src/node_version.h
2013-05-27 14:46:52 -07:00
isaacs
ec576235f1 http: Use writev instead of the hacky hot end 2013-05-09 09:35:32 -07:00
Ben Noordhuis
d3ddee61c2 http: forward-port missing bits from 01e2920
Forward-port the comments from commit 01e2920 (v0.10) to the master
branch. Everything else from that patch already exists in master.

It didn't merge cleanly because lib/http.js has been split up in
several files.
2013-04-29 14:12:25 +02:00
Fedor Indutny
df8a4f8f07 http: write buffers when chunked to embrace writev 2013-04-27 21:03:40 +04:00
isaacs
025f9133bb http: Don't try to destroy nonexistent sockets
Fixes #3740

In the case of pipelined requests, you can have a situation where
the socket gets destroyed via one req/res object, but then trying
to destroy *another* req/res on the same socket will cause it to
call undefined.destroy(), since it was already removed from that
message.

Add a guard to OutgoingMessage.destroy and IncomingMessage.destroy
to prevent this error.
2013-04-22 10:38:14 -07:00
Timothy J Fontaine
951e0b69fa http: split Client into _http_client.js 2013-04-17 00:08:28 +02:00
Timothy J Fontaine
6717fdccb4 http: move Server and ServerResponse out 2013-04-17 00:08:28 +02:00
Timothy J Fontaine
dc9f97b7b9 http: move OutgoingMessage into it's own file 2013-04-17 00:08:28 +02:00