为什么curl截断这个查询字符串? [英] Why is curl truncating this query string?

查看:215
本文介绍了为什么curl截断这个查询字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信这个答案将是一些令人痛苦的字符编码问题...

I'm sure the answer to this is going to be some painfully obvious character encoding issue...

我在命令行中使用curl测试一些端点在python应用程序。端点接受纬度和经度的网址参数。没有什么太特别。我输入命令:

I'm using curl on the command line to test some endpoints in a python app. The endpoint takes url params of latitude and longitude. Nothing too special. I put in the command:

curl -v -L http://localhost:5000/pulse/?lat=41.225&lon=-73.1

服务器响应,使用详细的curl输出:

Server responds, with verbose curl output:

* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET /pulse/?lat=41.225 HTTP/1.1
> User-Agent: curl/7.21.6 (i686-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
> Host: localhost:5000
> Accept: */*
> 
* HTTP 1.0, assume close after body
< HTTP/1.0 500 INTERNAL SERVER ERROR
< Content-Type: application/json
< Content-Length: 444
< Server: Werkzeug/0.8.1 Python/2.7.2+
< Date: Wed, 01 Feb 2012 17:06:29 GMT
< 
{
    "msg": "TypeError: float() argument must be a string or a number", 
    "flag": 0, 
    "stack": [
        "Traceback (most recent call last):", 
        "  File \"engine.py\", line 139, in dispatch_request", 
        "    return getattr(self, 'action_'+endpoint)(request, **values)", 
        "  File \"engine.py\", line 818, in action_getpulse", 
        "    lon = float(request.args.get('lon'))"
    ], 
    "err": 1
* Closing connection #0
}
[1]+  Done

在该转储的第二行,显然第二个参数 lon ,未发送。我究竟做错了什么?谢谢。

On the second line of that dump, it's obvious that the second param, lon, isn't being sent. What am I doing wrong? Thanks.

推荐答案

问题的答案,我做错了什么,是shell看到& code>& ),并认为这是命令的结尾(并将其放入背景)。你需要引用它,这就是为什么引用字符串的答案工作。您可以轻松地执行此操作:

The answer to the question, "what am I doing wrong," is that the shell sees the ampersand (&) and thinks that's the end of the command (and puts it into the background). You need to quote it, which is why the answers that quoted the string work. You could just as easily run this:

curl -v -L "http://localhost:5000/pulse/?lat=41.225&lon=-73.1"

这篇关于为什么curl截断这个查询字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆