http post请求标头既设置又未设置?

时间:2017-04-09 10:19:42

标签: php ios objective-c post

我制作了一款iOS应用,其中一部分将http发布请求发送到服务器上的php。

我刚刚对我的代码进行了一些更改(包括应用程序和php中的代码),而且我已经破坏了一些东西,但我不确定是什么。我不是PHP专家,虽然我很了解app(obj-c)。

在我的php中我有:

$result = array(); //create empty array to fill with results to send back to app

if (isset($_POST["level"])) //this is what is meant to happen
{
        $result["level is set"] = "true";
        //do some stuff
}
else   //this is not meant to happen
{
        $result["level is set"] = "false";

        foreach (getallheaders() as $name => $value)  //check to see what actually is set
       {
        $result[$name] =  $value;
       }
}

然后我在我的应用程序中得到的结果数组是:

[responseData: {
    Accept = "*/*";
    "Accept-Encoding" = "gzip, deflate";
    "Accept-Language" = "en-us";
    Authorization = "Basic emlwemlwYXBwdXNlcjpEJkIye28sU34tO28=";
    Connection = "keep-alive";
    "Content-Length" = 16;
    "Content-Type" = "multipart/form-data, boundary=--boundary";
    Host = my server;
    "User-Agent" = "MyAppName/7 CFNetwork/808.0.2 Darwin/16.4.0";
    "level is set" = false;
    level = 1;
}]

请注意"等级"当我遍历我的标题时设置,但它跟随" else"只有" level"才能遵循的路径没有设定。

有没有人有任何想法我做错了什么?我猜它是盯着我的东西。

感谢

0 个答案:

没有答案