简体   繁体   English

POST不起作用

[英]POST don't work

all! 所有! I have php page like this: 我有这样的PHP页面:

    <?php 
 if(isset($_POST['userid']) and  isset($_POST['dlspeed']) )
 {
  $userid=$_POST['userid'];
  $dlspeed=$_POST['dlspeed'];
  $timestamp =date("y-m-d H:i");
  $db_conn = mysql_connect('localhost', "root", "asdk78623r");
  mysql_select_db("speedtest", $db_conn);
  $query='INSERT INTO status VALUE (NULL, "'.$userid.'", "'.$dlspeed.'", "'.$timestamp.'")';
  $result=mysql_query($query,$db_conn);
 }
?

And from C# I do post: 从C#中我发布:

      HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(pageurl);

                byte[] buffer = Encoding.ASCII.GetBytes(data);
                System.Net.ServicePointManager.Expect100Continue = false;
                WebReq.SendChunked = false;
                WebReq.Expect = null;
                WebReq.KeepAlive = false;

                //I try also setting proxy
                // WebReq.Proxy = new WebProxy("192.168.0.107", 3128);
                //Our method is post, otherwise the buffer (postvars) would be useless
                WebReq.Method = "POST";
                //We use form contentType, for the postvars.
                WebReq.ContentType = "application/x-www-form-urlencoded";
                //The length of the buffer (postvars) is used as contentlength.
                WebReq.ContentLength = buffer.Length;
                //We open a stream for writing the postvars
                Stream PostData = WebReq.GetRequestStream();
                //Now we write, and afterwards, we close. Closing is always important!
                PostData.Write(buffer, 0, buffer.Length);
                PostData.Close();

              //posted data is not inserted in db
//and in follow line code Ive got error: The remote server returned an error: (417)  //Expectation failed
                HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();  

What I do wrong? 我做错了什么? With follow curl command post works fine: 使用Follow curl命令可以正常工作:

curl -d "userid=SW783IC2QDHFYU6P4XKO&dlspeed=814,602968463903&timestamp=2012-2-23 19:29:33" pageurl

Any idea, suggestions, reconsiderations? 有什么想法,建议,重新考虑吗?

There's multiple options why this may happen. 有多种选择可能会导致这种情况发生。

http://www.checkupdown.com/status/E417.html http://www.checkupdown.com/status/E417.html

One of the reasons may be: http://haacked.com/archive/2004/05/15/http-web-request-expect-100-continue.aspx 原因之一可能是: http : //haacked.com/archive/2004/05/15/http-web-request-expect-100-continue.aspx

install a program that logs your requests and what they contain (fiddler2 works great is free and easy to use, there are several very similar but can't remember their names atm) 安装一个程序来记录您的请求及其所包含的内容(fiddler2很好用,是免费且易于使用的,有几个非常相似,但记不得它们的名称是atm)

try to see if you find any headers that shouldn't be there, and if you can't for your life figure it out someone here might help you once you post that. 尝试查看是否找到了不应该存在的标头,如果您一生都无法找到它,请在发帖后找到这里的人可能会帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM