| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 75ecf8e commit 6f312b3
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,7 @@ namespace node { | |||
| 17 | 17 | V(FSREQWRAP) \ | |
| 18 | 18 | V(GETADDRINFOREQWRAP) \ | |
| 19 | 19 | V(GETNAMEINFOREQWRAP) \ | |
| 20 | + V(HTTPPARSER) \ | ||
| 20 | 21 | V(JSSTREAM) \ | |
| 21 | 22 | V(PIPEWRAP) \ | |
| 22 | 23 | V(PIPECONNECTWRAP) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,8 @@ | |||
| 3 | 3 | #include "node_http_parser.h" | |
| 4 | 4 | #include "node_revert.h" | |
| 5 | 5 | ||
| 6 | - #include "base-object.h" | ||
| 7 | - #include "base-object-inl.h" | ||
| 6 | + #include "async-wrap.h" | ||
| 7 | + #include "async-wrap-inl.h" | ||
| 8 | 8 | #include "env.h" | |
| 9 | 9 | #include "env-inl.h" | |
| 10 | 10 | #include "stream_base.h" | |
@@ -148,10 +148,10 @@ struct StringPtr { | |||
| 148 | 148 | }; | |
| 149 | 149 | ||
| 150 | 150 | ||
| 151 | - class Parser : public BaseObject { | ||
| 151 | + class Parser : public AsyncWrap { | ||
| 152 | 152 | public: | |
| 153 | 153 | Parser(Environment* env, Local<Object> wrap, enum http_parser_type type) | |
| 154 | - : BaseObject(env, wrap), | ||
| 154 | + : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_HTTPPARSER), | ||
| 155 | 155 | current_buffer_len_(0), | |
| 156 | 156 | current_buffer_data_(nullptr) { | |
| 157 | 157 | Wrap(object(), this); | |
@@ -165,6 +165,11 @@ class Parser : public BaseObject { | |||
| 165 | 165 | } | |
| 166 | 166 | ||
| 167 | 167 | ||
| 168 | + size_t self_size() const override { | ||
| 169 | + return sizeof(*this); | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + | ||
| 168 | 173 | HTTP_CB(on_message_begin) { | |
| 169 | 174 | num_fields_ = num_values_ = 0; | |
| 170 | 175 | url_.Reset(); | |
@@ -286,8 +291,10 @@ class Parser : public BaseObject { | |||
| 286 | 291 | ||
| 287 | 292 | argv[A_UPGRADE] = Boolean::New(env()->isolate(), parser_.upgrade); | |
| 288 | 293 | ||
| 294 | + Environment::AsyncCallbackScope callback_scope(env()); | ||
| 295 | + | ||
| 289 | 296 | Local<Value> head_response = | |
| 290 | - cb.As<Function>()->Call(obj, arraysize(argv), argv); | ||
| 297 | + MakeCallback(cb.As<Function>(), arraysize(argv), argv); | ||
| 291 | 298 | ||
| 292 | 299 | if (head_response.IsEmpty()) { | |
| 293 | 300 | got_exception_ = true; | |
@@ -322,7 +329,7 @@ class Parser : public BaseObject { | |||
| 322 | 329 | Integer::NewFromUnsigned(env()->isolate(), length) | |
| 323 | 330 | }; | |
| 324 | 331 | ||
| 325 | - Local<Value> r = cb.As<Function>()->Call(obj, arraysize(argv), argv); | ||
| 332 | + Local<Value> r = MakeCallback(cb.As<Function>(), arraysize(argv), argv); | ||
| 326 | 333 | ||
| 327 | 334 | if (r.IsEmpty()) { | |
| 328 | 335 | got_exception_ = true; | |
@@ -345,7 +352,9 @@ class Parser : public BaseObject { | |||
| 345 | 352 | if (!cb->IsFunction()) | |
| 346 | 353 | return 0; | |
| 347 | 354 | ||
| 348 | - Local<Value> r = cb.As<Function>()->Call(obj, 0, nullptr); | ||
| 355 | + Environment::AsyncCallbackScope callback_scope(env()); | ||
| 356 | + | ||
| 357 | + Local<Value> r = MakeCallback(cb.As<Function>(), 0, nullptr); | ||
| 349 | 358 | ||
| 350 | 359 | if (r.IsEmpty()) { | |
| 351 | 360 | got_exception_ = true; | |
@@ -585,7 +594,7 @@ class Parser : public BaseObject { | |||
| 585 | 594 | parser->current_buffer_len_ = nread; | |
| 586 | 595 | parser->current_buffer_data_ = buf->base; | |
| 587 | 596 | ||
| 588 | - cb.As<Function>()->Call(obj, 1, &ret); | ||
| 597 | + parser->MakeCallback(cb.As<Function>(), 1, &ret); | ||
| 589 | 598 | ||
| 590 | 599 | parser->current_buffer_len_ = 0; | |
| 591 | 600 | parser->current_buffer_data_ = nullptr; | |
@@ -659,7 +668,7 @@ class Parser : public BaseObject { | |||
| 659 | 668 | url_.ToString(env()) | |
| 660 | 669 | }; | |
| 661 | 670 | ||
| 662 | - Local<Value> r = cb.As<Function>()->Call(obj, arraysize(argv), argv); | ||
| 671 | + Local<Value> r = MakeCallback(cb.As<Function>(), arraysize(argv), argv); | ||
| 663 | 672 | ||
| 664 | 673 | if (r.IsEmpty()) | |
| 665 | 674 | got_exception_ = true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ const tls = require('tls'); | |||
| 11 | 11 | const zlib = require('zlib'); | |
| 12 | 12 | const ChildProcess = require('child_process').ChildProcess; | |
| 13 | 13 | const StreamWrap = require('_stream_wrap').StreamWrap; | |
| 14 | + const HTTPParser = process.binding('http_parser').HTTPParser; | ||
| 14 | 15 | const async_wrap = process.binding('async_wrap'); | |
| 15 | 16 | const pkeys = Object.keys(async_wrap.Providers); | |
| 16 | 17 | ||
@@ -106,6 +107,8 @@ zlib.createGzip(); | |||
| 106 | 107 | ||
| 107 | 108 | new ChildProcess(); | |
| 108 | 109 | ||
| 110 | + new HTTPParser(HTTPParser.REQUEST); | ||
| 111 | + | ||
| 109 | 112 | process.on('exit', function() { | |
| 110 | 113 | if (keyList.length !== 0) { | |
| 111 | 114 | process._rawDebug('Not all keys have been used:'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments