如何在 XP 上调试通过 cURL 发送到 Wordpress 的 Atompub POST 阿帕奇 2.2 + X调试

发布于 2024-07-11 02:24:50 字数 104 浏览 9 评论 0 原文

我一直使用 NetBeans 作为 XDebug 交互式调试客户端。 但似乎它只支持将调试器附加到通过 Firefox 调用的脚本。 我想在通过 cURL 调用请求解析脚本时单步执行该脚本。

I've been using NetBeans as the XDebug interactive debugging client. But seems like it only supports attaching debuggers to scripts that are invoked via Firefox. I want to step through the request parse script when it's invoked via cURL.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷雾森÷林ヴ 2024-07-18 02:24:50

我找到了答案。 首先,我通过右键单击 netbeans 中的 wordpress 项目并选择“调试”来附加调试器。 这将在 Firefox 中打开博客,网址中包含“XDEBUG_SESSION_START=netbeans-xdebug”参数(例如“http://localhost/wordpress/?XDEBUG_SESSION_START=netbeans-xdebug”)。

然后我从命令行调用 cURL,确保设置名称/值为 XDEBUG_SESSION/netbeans-xdebug 的 cookie:

>curl "http://localhost/wordpress/wp-app.php/posts" -X POST -H "Content-type: application/atom+xml" -v -L -k -u admin:password --data @post_atom_entry_bad.xml -o post_bad_response.txt -b XDEBUG_SESSION=netbeans-xdebug
* About to connect() to localhost port 80 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 80 (#0)
* Server auth using Basic with user 'admin'
> POST /wordpress/wp-app.php/posts HTTP/1.1
> Authorization: Basic YWRtaW46d2Fuc3Vp
> User-Agent: curl/7.19.1 (i586-pc-mingw32msvc) libcurl/7.19.1 OpenSSL/0.9.8i zlib/1.2.3
> Host: localhost
> Accept: */*
> Cookie: XDEBUG_SESSION=netbeans-xdebug
> Content-type: application/atom+xml
> Content-Length: 302
>
} [data not shown]
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   302    0     0    0   302      0     74 --:--:--  0:00:04 --:--:--     0

此时 cURL 在我在 wp-app.php、AtomParser-> 中设置的第 283 行处设置的断点处停止;handle_request(),我可以单步执行代码。

单击 F5(继续)后,服务器将响应发送回 cURL:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   302    0     0    0   302      0      2 --:--:--  0:02:17 --:--:--     0< HTTP/1.1 400 Bad Request
< Date: Mon, 15 Dec 2008 17:47:06 GMT
< Server: Apache/2.2.9 (Win32) DAV/2 mod_ssl/2.2.9 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.6
< X-Powered-By: PHP/5.2.6
< Content-Length: 0
< Connection: close
< Content-Type: text/plain
<
100   302    0     0    0   302      0      2 --:--:--  0:02:18 --:--:--     0* Closing connection #0


>

完成。 如果能从其他交互式调试客户端(例如 notepad++)获取示例,那就太好了。

I figured out the answer. First I attached a debugger by right-clicking on the wordpress project in netbeans and choosing "debug". This will open the blog in firefox with the "XDEBUG_SESSION_START=netbeans-xdebug" param included in the url (e.g. "http://localhost/wordpress/?XDEBUG_SESSION_START=netbeans-xdebug").

Then I invoked cURL from the command line, making sure to set a cookie with the name/value XDEBUG_SESSION/netbeans-xdebug:

>curl "http://localhost/wordpress/wp-app.php/posts" -X POST -H "Content-type: application/atom+xml" -v -L -k -u admin:password --data @post_atom_entry_bad.xml -o post_bad_response.txt -b XDEBUG_SESSION=netbeans-xdebug
* About to connect() to localhost port 80 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 80 (#0)
* Server auth using Basic with user 'admin'
> POST /wordpress/wp-app.php/posts HTTP/1.1
> Authorization: Basic YWRtaW46d2Fuc3Vp
> User-Agent: curl/7.19.1 (i586-pc-mingw32msvc) libcurl/7.19.1 OpenSSL/0.9.8i zlib/1.2.3
> Host: localhost
> Accept: */*
> Cookie: XDEBUG_SESSION=netbeans-xdebug
> Content-type: application/atom+xml
> Content-Length: 302
>
} [data not shown]
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   302    0     0    0   302      0     74 --:--:--  0:00:04 --:--:--     0

At this point cURL halts at the breakpoint I have set at line 283 in wp-app.php, AtomParser->handle_request(), and I can step through the code.

Once I click F5 (continue), the server sends the response back to cURL:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   302    0     0    0   302      0      2 --:--:--  0:02:17 --:--:--     0< HTTP/1.1 400 Bad Request
< Date: Mon, 15 Dec 2008 17:47:06 GMT
< Server: Apache/2.2.9 (Win32) DAV/2 mod_ssl/2.2.9 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.6
< X-Powered-By: PHP/5.2.6
< Content-Length: 0
< Connection: close
< Content-Type: text/plain
<
100   302    0     0    0   302      0      2 --:--:--  0:02:18 --:--:--     0* Closing connection #0


>

Done. Would be great to get examples from other interactive debugging clients like notepad++.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文