summaryrefslogtreecommitdiff
path: root/src/node_http_parser.cc
AgeCommit message (Collapse)Author
2016-04-19http: skip body and next message of CONNECT resFedor Indutny
When handling a response to `CONNECT` request - skip message body and do not attempt to parse the next message. `CONNECT` requests are used in similar sense to HTTP Upgrade. Fix: https://github.com/nodejs/node/pull/6198 PR-URL: https://github.com/nodejs/node/pull/6279 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-04-18src: don't set non-primitive values on templatesBen Noordhuis
V8 is going to disallow non-primitive values on v8::FunctionTemplate and v8::ObjectTemplate because those can't be shared across contexts. Fixes: https://github.com/nodejs/node/issues/6216 PR-URL: https://github.com/nodejs/node/pull/6228 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-04-05src: use size_t for http parser array size fieldsBen Noordhuis
Make the `num_values_` and `num_fields_` unsigned and remove an erroneous comment. PR-URL: https://github.com/nodejs/node/pull/5969 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-04-05src: replace ARRAY_SIZE with typesafe arraysizeBen Noordhuis
To prevent `ARRAY_SIZE(&arg)` (i.e., taking the array size of a pointer) from happening again. PR-URL: https://github.com/nodejs/node/pull/5969 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-28src,http_parser: remove KickNextTick callTrevor Norris
Now that HTTPParser uses MakeCallback it is unnecessary to manually process the nextTickQueue. The KickNextTick function is now no longer needed so code has moved back to node::MakeCallback to simplify implementation. Include minor cleanup moving Environment::tick_info() call below the early return to save an operation. PR-URL: https://github.com/nodejs/node/pull/5756 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
2016-03-01http_parser: use `MakeCallback`Trevor Norris
Make `HTTPParser` an instance of `AsyncWrap` and make it use `MakeCallback`. This means that async wrap hooks will be called on consumed TCP sockets as well as on non-consumed ones. Additional uses of `AsyncCallbackScope` are necessary to prevent improper state from progressing that triggers failure in the test-http-pipeline-flood.js test. Optimally this wouldn't be necessary, but for the time being it's the most sure way to allow operations to proceed as they have. Fix: https://github.com/nodejs/node/issues/4416 PR-URL: https://github.com/nodejs/node/pull/5419 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2016-02-12src: add AsyncCallbackScopeTrevor Norris
Add a scope that will allow MakeCallback to know whether or not it's currently running. This will prevent nextTickQueue and the MicrotaskQueue from being processed recursively. It is also required to wrap the bootloading stage since it doesn't run within a MakeCallback. Ref: https://github.com/nodejs/node-v0.x-archive/issues/9245 PR-URL: https://github.com/nodejs/node/pull/4507 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-12-17http_parser: use pushValueToArray for headersTrevor Norris
For performance add headers to the headers Array by pushing them on from JS. Benchmark added to demonstrate this case. PR-URL: https://github.com/nodejs/node/pull/3780 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-10-14http: fix stalled pipeline bugFedor Indutny
This is a two-part fix: - Fix pending data notification in `OutgoingMessage` to notify server about flushed data too - Fix pause/resume behavior for the consumed socket. `resume` event is emitted on a next tick, and `socket._paused` can already be `true` at this time. Pause the socket again to avoid PAUSED error on parser. Fix: https://github.com/nodejs/node/issues/3332 PR-URL: https://github.com/nodejs/node/pull/3342 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-09-19http_parser: do not dealloc during kOnExecuteFedor Indutny
`freeParser` deallocates `Parser` instances early if they do not fit into the free list. This does not play well with recent socket consumption change, because it will try to deallocate the parser while executing on its stack. Regression was introduced in: 1bc4468 Fix: https://github.com/nodejs/node/issues/2928 PR-URL: https://github.com/nodejs/node/pull/2956 Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2015-09-06src: replace usage of v8::Handle with v8::LocalMichaƫl Zasso
v8::Handle is deprecated: https://codereview.chromium.org/1224623004 PR-URL: https://github.com/nodejs/io.js/pull/2202 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-26http_parser: consume StreamBase instanceFedor Indutny
Consume StreamBase instance and operate on incoming data directly without allocating Buffer instances. Improves performance. PR-URL: https://github.com/nodejs/node/pull/2355 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-08-26src: missing Exception::Error in node_http_parserJeremiah Senkpiel
Fixes: 75adde07f9a2de7f38a67bec72bd377d450bdb52 PR-URL: https://github.com/nodejs/node/pull/2550 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-05-04src: fix -Wmissing-field-initializers warningBen Noordhuis
Fix the following (non-serious) compiler warning: ../src/node_http_parser.cc:558:1: warning: missing initializer for member 'http_parser_settings::on_chunk_header' [-Wmissing-field-initializers] }; ^ ../src/node_http_parser.cc:558:1: warning: missing initializer for member 'http_parser_settings::on_chunk_complete' [-Wmissing-field-initializers] Introduced in commit b3a7da1 ("deps: update http_parser to 2.5.0"). PR-URL: https://github.com/iojs/io.js/pull/1606 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-01-13http: optimize on_headers_completeBert Belder
Use an array instead of an object to pass a parsed header chunk from c++ to javascript. This offers a 5-10% speedup on the http_simple benchmark, as evidenced by running: ab -k -t 100 -c 100 http://127.0.0.1:8000/bytes/100 PR: https://github.com/iojs/io.js/pull/292 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-12Remove excessive copyright/license boilerplateisaacs
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-07src: pass Isolate to additional locationsTrevor Norris
Due to a recent V8 upgrade, more methods require Isolate as an argument. PR-URL: https://github.com/iojs/io.js/pull/244 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
2014-10-23src: mark more destructors with override keywordBen Noordhuis
The previous commits fixed oversights in destructors that should have been marked virtual but weren't. This commit marks destructors from derived classes with the override keyword.
2014-10-23src: replace NULL with nullptrBen Noordhuis
Now that we are building with C++11 features enabled, replace use of NULL with nullptr. The benefit of using nullptr is that it can never be confused for an integral type because it does not support implicit conversions to integral types except boolean - unlike NULL, which is defined as a literal `0`.
2014-10-13src: attach env directly to api functionsBen Noordhuis
Attach the per-context execution environment directly to API functions. Rationale: * Gets node one step closer to multi-isolate readiness. * Avoids multi-context confusion, e.g. when the caller and callee live in different contexts. * Avoids expensive calls to pthread_getspecific() on platforms where V8 does not know how to use the thread-local storage directly. (Linux, the BSDs.) PR-URL: https://github.com/node-forward/node/pull/18 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-10-12src: replace assert() with CHECK()Ben Noordhuis
Mechanically replace assert() statements with UNREACHABLE(), CHECK(), or CHECK_{EQ,NE,LT,GT,LE,GE}() statements. The exceptions are src/node.h and src/node_object_wrap.h because they are public headers. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-10-12src: remove unnecessary HandleScopesBen Noordhuis
API callback functions don't need to create a v8::HandleScope instance because V8 already creates one in the JS->C++ adapter frame. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-05lib, src: don't make http parser handles weakBen Noordhuis
Weak handles put strain on the garbage collector and the parser handle doesn't need to be weak in the first place. This change should improve GC times on busy servers a little. Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05src: fix handle leak in Parser::Execute()Ben Noordhuis
Fix a resource leak where an intermediate Local<Context> handle in Environment::GetCurrent() got leaked into whatever HandleScope was further up the stack. Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-05-30src: replace CONTAINER_OF with type-safe functionBen Noordhuis
Replace the CONTAINER_OF macro with a template function that is as type-safe as a reinterpret_cast<> of an arbitrary pointer can be made. Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-04-02node: add signature to SET_PROTOTYPE_METHODC. Scott Ananian
This prevents segfaults when a native method is reassigned to a different object (which corrupts args.This()). When unwrapping, clients should use args.Holder() instead of args.This(). Closes #6690. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-03-13src: update to v8 3.24 APIsFedor Indutny
2014-02-22src: remove `node_isolate` from sourceFedor Indutny
fix #6899
2014-01-27node: register modules from DSO constructorsKeith M Wesolowski
Built-in modules should be automatically registered, replacing the static module list. Add-on modules should also be automatically registered via DSO constructors. This improves flexibility in adding built-in modules and is also a prerequisite to pure-C addon modules.
2013-12-20http: parse the status message in a http response.Cam Swords
2013-11-12base-object: add BaseObjectTrevor Norris
BaseObject is a class that just handles the Persistent handle attached to the class instance. This also removed WeakObject. Reordering the inheritance chain helps prevent unneeded calls on instances that don't call MakeCallback.
2013-11-11src: fix Environment::GetCurrent() usageBen Noordhuis
Create a HandleScope before calling the Environment::GetCurrent() that takes a v8::Isolate* as an argument because it creates a handle with the call to v8::Isolate::CurrentContext().
2013-11-08src: remove container_of, use CONTAINER_OFBen Noordhuis
CONTAINER_OF was introduced a while ago but was not used consistently everywhere yet. This commit fixes that. Why CONTAINER_OF instead of container_of? The former makes it crystal clear that it's a macro, not a function.
2013-10-31async-wrap: integrate with WeakObjectTrevor Norris
Making WeakObject inherit from AsyncWrap allows us to peak into almost all the MakeCallback calls in Node internals.
2013-10-29src: shorten Object{Wrap,Unwrap}Trevor Norris
Going back to the original names of Wrap/Unwrap now that most all the class members that duplicate the name and functionality have been removed.
2013-10-29src: don't use WeakObject::UnwrapTrevor Norris
Switch out to use UnwrapObject from util.h.
2013-10-28http: remove MethodToString()Ben Noordhuis
The list of supported HTTP methods is available in JS land now so there is no longer any need to pass a stringified version of the method to the parser callback, it can look up the method name for itself. Saves a call to v8::Eternal::Get() in the common case and a costly v8::String::NewFromOneByte() in the uncommon case.
2013-10-28http: expose supported methodsBen Noordhuis
Expose the list of supported HTTP methods as a property on the 'http' module object. Fixes #6422.
2013-10-17cpplint: disallow if one-linersFedor Indutny
2013-10-17cpplint: disallow comma-first in C++Fedor Indutny
2013-10-16http_parser: expose pause/resume method for parserTimothy J Fontaine
2013-09-25src: remove ObjectWrap dependency from coreBen Noordhuis
Drop the ObjectWrap dependency in favor of an internal WeakObject class. Let's us stop worrying about API and ABI compatibility when making changes to the way node.js deals with weakly persistent handles internally.
2013-09-06src: add multi-context supportBen Noordhuis
This commit makes it possible to use multiple V8 execution contexts within a single event loop. Put another way, handle and request wrap objects now "remember" the context they belong to and switch back to that context when the time comes to call into JS land. This could have been done in a quick and hacky way by calling v8::Object::GetCreationContext() on the wrap object right before making a callback but that leaves a fairly wide margin for bugs. Instead, we make the context explicit through a new Environment class that encapsulates everything (or almost everything) that belongs to the context. Variables that used to be a static or a global are now members of the aforementioned class. An additional benefit is that this approach should make it relatively straightforward to add full isolate support in due course. There is no JavaScript API yet but that will be added in the near future. This work was graciously sponsored by GitHub, Inc.
2013-08-14http: speed up callbacks, use array indicesBen Noordhuis
Use array indices rather than named properties to store callbacks on the HTTPParser object. Speeds up the http benchmarks by a few percent.
2013-08-09src: use v8::String::NewFrom*() functionsBen Noordhuis
* Change calls to String::New() and String::NewSymbol() to their respective one-byte, two-byte and UTF-8 counterparts. * Add a FIXED_ONE_BYTE_STRING macro that takes a string literal and turns it into a v8::Local<v8::String>. * Add helper functions that make v8::String::NewFromOneByte() easier to work with. Said function expects a `const uint8_t*` but almost every call site deals with `const char*` or `const unsigned char*`. Helps us avoid doing reinterpret_casts all over the place. * Code that handles file system paths keeps using UTF-8 for backwards compatibility reasons. At least now the use of UTF-8 is explicit. * Remove v8::String::NewSymbol() entirely. Almost all call sites were effectively minor de-optimizations. If you create a string only once, there is no point in making it a symbol. If you are create the same string repeatedly, it should probably be cached in a persistent handle.
2013-07-31src: more lint after cpplint tighteningBen Noordhuis
Commit 847c6d9 adds a 'project headers before system headers' check to cpplint. Update the files in src/ to make the linter pass again.
2013-07-31src: lint c++ codeFedor Indutny
2013-07-06lib, src: upgrade after v8 api changeBen Noordhuis
This is a big commit that touches just about every file in the src/ directory. The V8 API has changed in significant ways. The most important changes are: * Binding functions take a const v8::FunctionCallbackInfo<T>& argument rather than a const v8::Arguments& argument. * Binding functions return void rather than v8::Handle<v8::Value>. The return value is returned with the args.GetReturnValue().Set() family of functions. * v8::Persistent<T> no longer derives from v8::Handle<T> and no longer allows you to directly dereference the object that the persistent handle points to. This means that the common pattern of caching oft-used JS values in a persistent handle no longer quite works, you first need to reconstruct a v8::Local<T> from the persistent handle with the Local<T>::New(isolate, persistent) factory method. A handful of (internal) convenience classes and functions have been added to make dealing with the new API a little easier. The most visible one is node::Cached<T>, which wraps a v8::Persistent<T> with some template sugar. It can hold arbitrary types but so far it's exclusively used for v8::Strings (which was by far the most commonly cached handle type.)
2013-07-03{stream,udp,tls}_wrap: remove unused offset/lengthTrevor Norris
The function arguments offset and length are now no longer used since all I/O requests now use discretely allocated memory.
2013-03-20src: pass Isolate to all applicable apiTrevor Norris
Update the api to pass node_isolate to all supported methods. Much thanks to Ben Noordhuis and his work in 51f6e6a.