dongxiaoxing3058 2013-12-05 05:46
浏览 192

当我使用iPhone执行HTTP POST请求时,HTTP标头消失

i am new to Objective c and i stuck in a problem which only appears when i do HTTP POST request.
I do HTTP request with my iPhone and i expect the server returns me something like this in the header (this is the respond header from other server):

{
"Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
Connection = close;
"Content-Length" = 0;
"Content-Type" = "text/html";
Date = "something";
Expires = "something";
Location = "/mylocation/10"; <--- this is what i want
Pragma = "no-cache";
Server = "Apache/2.2.3 (CentOS)";
"Set-Cookie" = "something";
"X-Powered-By" = "PHP/5.3.3";
}

When i do a successful posting ,it does the function that is want and returns an empty response with a header like this:

{
"Cache-Control" = "max-age=0, no-cache";
Connection = close;
"Content-Length" = 0;
"Content-Type" = "text/html";
Date = "something";
Server = "Apache/2.2.14 (Ubuntu)";
}

Even i add the headers like "Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0", they will not be displayed in the respond header.
What should i do to get the correct header?

Additional information
I use ASIFormDataRequest to make request, here is the code that i set header:

{
__block ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:something];
[request setRequestMethod:@"POST"];
[request addRequestHeader:@"Authorization" value:@"something"];
[request addRequestHeader:@"Accept" value:@"application/json,*/*;q=0.8"];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
}


And this is how i get the respond headers:

{
[request startSynchronous];
NSLog(@"%@", [request responseHeaders]);
}
  • 写回答

1条回答 默认 最新

  • dongza1708 2013-12-06 06:26
    关注

    Location headers will be sent only during the time of redirection. When we add a resource using PUT method the newly created URL will be added in the Location header and will be sent as part of the response. This also happens during 3xx redirection.

    评论

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R