0

发布数据 =>

Accept:application/json, text/javascript, */*; q=0.01

Accept-Charset:ISO-8859-9,utf-8;q=0.7,*;q=0.3

Accept-Encoding:gzip,deflate,sdch

Accept-Language:tr-TR,tr;q=0.8,en-US;q=0.6,en;q=0.4

Connection:keep-alive

Content-Length:0

Cookie:pfu=32904422; pfp=PO7PkdBDUwKoMG4FqkriwDLF7jrwcHBEoVqnX2i3; pfe=1386687638; 
logged_in=1; tmgioct=5hRBmncU3JQtInFOSa4qqoHX

Host:www.tumblr.com

Origin:http://www.tumblr.com

Referer:http://www.tumblr.com/customize/hayirasla?redirect_to=http%3A%2F%2Fhayirasla.tumblr.com%2F

User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11

X-Requested-With:XMLHttpRequest        

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.Method = "POST";

        request.Headers.Add("Origin", "http://www.tumblr.com");
        request.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); //Bu üstbilgi uygun özellik veya yöntem kullanılarak değiştirilmelidir.
        request.Headers.Add(HttpRequestHeader.Cookie, "pfu=32904422;pfe=1386687638;pfp=PO7PkdBDUwKoMG4FqkriwDLF7jrwcHBEoVqnX2i3;logged_in=1;");
        return new StreamReader(((HttpWebResponse)request.GetResponse()).GetResponseStream()).ReadToEnd();
4

2 回答 2

1

您不能通过 HttpWebRequest.Headers.Add()添加标头

某些标头设置为受限

    private static readonly string[] RestrictedHeaders = new[]
        {
            "Accept", "Connection", "Content-Type", "Content-Length", "Date", "Expect", "Host", "Range", "Referer", "User-Agent"
        };

上面列出的所有标题都不能直接添加,只能通过使用来设置

//HttpWebRequest.[TheProperty] = value;
于 2012-12-28T18:04:38.233 回答
0

您忘记“填写”发布数据?!?因为我看到你发送的请求只有标题......

于 2012-12-10T17:25:21.240 回答