How to set status codes such as 401 and 403?

Setting a 404 in WordPress can be done quite easily using the set_404() method of WP_Query and the status_header() function. Here’s an example taken from WP::handle_404(): $wp_query->set_404(); status_header( 404 ); nocache_headers(); If I wanted my tag archive to be accessible to authenticated users only, setting a 404 page for non-authenticated users wouldn’t make sense because … Read more

HTTP POST Returns Error: 417 “Expectation Failed.”

When I try to POST to a URL it results in the following exception: The remote server returned an error: (417) Expectation Failed. Here’s a sample code: var client = new WebClient(); var postData = new NameValueCollection(); postData.Add(“postParamName”, “postParamValue”); byte[] responseBytes = client.UploadValues(“http://…”, postData); string response = Encoding.UTF8.GetString(responseBytes); // (417) Expectation Failed. Using an HttpWebRequest/HttpWebResponse … Read more

What is the http-header “X-XSS-Protection”?

So I’ve been toying around with HTTP for fun in telnet now (i.e. just typing in telnet google.com 80 and putting in random GETs and POSTs with different headers and the like) but I’ve come across something that google.com transmits in it’s headers that I don’t know. I’ve been looking through http://www.w3.org/Protocols/rfc2616/rfc2616.html and have found … Read more