0

我有一个服务器路由设置,它接受来自外部服务(PayPal)的 POST 请求。我以前可以通过访问路由函数this.request.body内部来获取所有详细信息action,但是在最近进行了流星更新之后,请求正文不再被正确解析,并且弄清楚为什么显然超出了我的技能水平。

我想我可以回滚更新以使一切恢复正常,但我正试图弄清楚发生了什么。

所以我的问题是: 为什么请求正文没有被正确解析?即使只是在大方向上点头也会非常感激,因为我在这里一无所知。

我的路线如下所示:

  this.route('ipnPay', {
    path: '/ipn/pay',
    where: 'server',
    action: function() {
        var request = this.request;

        console.log(request.body);
        //do other stuff
     }
   });

它曾经打印出如下所示的响应:

I20150727-18:09:46.656(-4)? { payment_request_date: 'Mon Jul 27 15:09:12 PDT 2015',
I20150727-18:09:46.657(-4)?   'transaction[0].id_for_sender_txn': '9PB44643108585943',
I20150727-18:09:46.657(-4)?   'transaction[0].receiver': 'tom@example.com',
I20150727-18:09:46.657(-4)?   'transaction[0].is_primary_receiver': 'false',
I20150727-18:09:46.657(-4)?   'transaction[0].id': '2HH18284E5553225C',
I20150727-18:09:46.657(-4)?   'transaction[0].status': 'Completed',
I20150727-18:09:46.658(-4)?   'transaction[0].paymentType': 'PERSONAL',
I20150727-18:09:46.658(-4)?   'transaction[0].status_for_sender_txn': 'Completed',
I20150727-18:09:46.658(-4)?   'transaction[0].pending_reason': 'NONE',
I20150727-18:09:46.658(-4)?   'transaction[0].amount': 'USD 266.67' }

但是在更新之后,请求正文被解析如下:

I20150727-18:32:35.812(-4)?    { payment_request_date: 'Mon Jul 27 15:32:22 PDT 2015',
I20150727-18:32:35.813(-4)?      transaction: 
I20150727-18:32:35.813(-4)?       { '0].id_for_sender_tx': '7WE57612VB713004Y',
I20150727-18:32:35.813(-4)?         '0].receive': 'tom@example.com',
I20150727-18:32:35.813(-4)?         '0].is_primary_receive': 'false',
I20150727-18:32:35.814(-4)?         '0].i': '8B180259507549243',
I20150727-18:32:35.814(-4)?         '0].statu': 'Completed',
I20150727-18:32:35.814(-4)?         '0].paymentTyp': 'PERSONAL',
I20150727-18:32:35.814(-4)?         '0].status_for_sender_tx': 'Completed',
I20150727-18:32:35.814(-4)?         '0].pending_reaso': 'NONE',
I20150727-18:32:35.814(-4)?         '0].amoun': 'USD 10.00' } }

因此,解析器现在尝试创建嵌套transaction对象,而不是第一个示例中的平面数据结构。但是键值被弄乱了..例如,第一个[被丢弃,最后一个字符也是如此(状态而不是状态,类型而不是类型等)

这里有什么想法吗??

我通过 ngrok 获得的实际请求的主体是:

payment_request_date=Mon+Jul+27+15%3A09%3A12+PDT+2015&return_url=http%3A//localhost%3A3000/events/mHsWRFFnQSiX7zyem&fees_payer=SENDER&ipn_notification_url=http%3A//fnfndr.ngrok.io/ipn/pay&sender_email=xyz%40example.com&verify_sign=AqIeeetyNLVMnJSHSYCajOvN1y05Ai91xec8RhhiuUk10kK0d-xTI6gp&test_ipn=1&transaction%5B0%5D.id_for_sender_txn=9PB44643108585943&transaction%5B0%5D.receiver=tom%40example.com&cancel_url=http%3A//localhost%3A3000/events/mHsWRFFnQSiX7zyem&transaction%5B0%5D.is_primary_receiver=false&pay_key=AP-12T24911F3500884N&action_type=PAY&transaction%5B0%5D.id=2HH18284E5553225C&transaction%5B0%5D.status=Completed&transaction%5B0%5D.paymentType=PERSONAL&preapproval_key=PA-33150539CY900002V&transaction%5B0%5D.status_for_sender_txn=Completed&transaction%5B0%5D.pending_reason=NONE&transaction_type=Adaptive+Payment+PAY&transaction%5B0%5D.amount=USD+266.67&status=COMPLETED&log_default_shipping_address_in_transaction=false&charset=windows-1252&notify_version=UNVERSIONED&reverse_all_parallel_payments_on_error=false

这些是我运行流星更新时更新的软件包:

bigdsk:inputmask             upgraded from 3.1.42 to 3.1.63
gadicohen:sitemaps           upgraded from 0.0.21 to 0.0.22
meteorhacks:kadira           upgraded from 2.21.0 to 2.22.1
meteorhacks:kadira-profiler  upgraded from 1.1.0 to 1.2.0
meteorhacks:npm              upgraded from 1.3.0 to 1.4.0
meteorhacks:subs-manager     upgraded from 1.4.0 to 1.5.2
momentjs:moment              upgraded from 2.9.0 to 2.10.5
nemo64:bootstrap             upgraded from 3.3.4_2 to 3.3.5_2
nemo64:bootstrap-data        upgraded from 3.3.4_1 to 3.3.5
nimble:restivus              upgraded from 0.6.6 to 0.8.1
simple:json-routes           added, version 1.0.3
summernote:standalone        upgraded from 0.6.7 to 0.6.13
4

1 回答 1

0

这种行为与这两个包有关:

nimble:restivus              upgraded from 0.6.6 to 0.8.1
simple:json-routes           added, version 1.0.3

我不完全理解如何或为什么,但它以某种方式干扰了 Iron:router 通常解析 HTTP 请求的方式。

因此,如果您遇到同样的错误,您可以降级或删除上面的软件包。

于 2015-07-29T01:44:00.440 回答