日期:2014-05-19  浏览次数:20738 次

关于 HTTP/1.1 400 Bad Request ( The data is invalid. ) 的问题
以下是我的测试程序
                  tc.Connect(HttpCommon.IPADDRESS,   HttpCommon.PORT);
ns   =   tc.GetStream();    
String   message   =   " ";
message+=   "GET   /club/garden.html   HTTP/1.1   \n ";


Byte[]   data   =Encoding.Unicode.GetBytes(message);
ns.Write(data,   0,   data.Length);

Thread.Sleep(TimeSpan.FromMilliseconds(500d));
string   recivestring= " ";
if   (ns.DataAvailable){
byte[]   buf   =   new   Byte[1024];
int   Len   =   ns.Read(buf,   0,   buf.Length);
recivestring   =   Encoding.ASCII.GetString(buf,   0,   Len);
}

this.richTextBox1.Text   =   recivestring;


调试得到的结果是:
              HTTP/1.1   400   Bad   Request   (   The   data   is   invalid.     )  

苦思中,不知问题出在哪儿,还请有经验者指点



------解决方案--------------------
\n
====>
\r\n
------解决方案--------------------
还是编码问题,哎
------解决方案--------------------
汗……………………………………
又碰到一个不结贴的!