http

Is there a reason to use BufferedReader over InputStreamReader when reading all characters?

I currently use the following function to do a simple HTTP GET. public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; //java.io.BufferedReader b = null; StringBuilder content = new StringBuilder(); try { s = (java.io.InputStrea...

How to respond to an alternate URI in a RESTful web service

I'm building a RESTful web service which has multiple URIs for one of its resources, because there is more than one unique identifier. Should the server respond to a GET request for an alternate URI by returning the resource, or should I send an HTTP 3xx redirect to the canonical URI? Is HTTP 303 (see also) the most appropriate redirect?...

Why does HttpCacheability.Private suppress ETags?

While writing a custom IHttpHandler I came across a behavior that I didn't expect concerning the HttpCachePolicy object. My handler calculates and sets an entity-tag (using the SetETag method on the HttpCachePolicy associated with the current response object). If I set the cache-control to public using the SetCacheability method everyth...

How to specify an authenticated proxy for a python http connection?

What's the best way to specify a proxy with username and password for an http connection in python? ...

Retrieving HTTP status code from loaded iframe with Javascript

I used the jQuery Form plugin for asynchronous form submission. For forms that contain files, it copies the form to a hidden iframe, submits it, and copies back the iframe's contents. The problem is that I can't figure out how to find what HTTP status code was returned by the server. For example, if the server returns 404, the data from ...

Manipulating content of pages that pass through an HTTP proxy (and calling Java)

I need to make a web proxy that adds annotations to the HTML of web pages that pass through. I'm hoping some decent software exists that can handle the HTTP proxying part of the application, so that, for the most part, I only have to worry about making a function that sits on the stream with a signature similar in intent to void proces...

Does new URL(...).openConnection() necessarily imply a POST?

If I create an HTTP java.net.URL and then call openConnection() on it, does it necessarily imply that an HTTP post is going to happen? I know that openStream() implies a GET. If so, how do you perform one of the other HTTP verbs without having to work with the raw socket layer? ...

HTTP POST question - I'm stuck

I have to POST some parameters to a URL outside my network, and the developers on the other side asked me to not use HTTP Parameters: instead I have to post my key-values in HTTP Headers. The fact is that I don't really understand what they mean: I tried to use a ajax-like post, with XmlHttp objects, and also I tried to write in the hea...

web proxy appliance

I'm looking for a cheap, simple, reliable web proxy appliance. Just a box that plugs into power and ethernet, and that redirects HTTP traffic to other existing web servers. It's intended for low volume web sites. Should I build a tiny, ultra low power pc to do this buy a cheap consumer-level router with this feature buy a dedicated en...

How do you make an etag that matches Apache?

I want to make an etag that matches what Apache produces. How does apache create it's etags? ...

When do you use POST and when do you use GET?

From what I can gather, there are three categories - never use GET and use POST, never use POST and use GET, and it doesn't matter which one you use. Am I correct in assuming those three cases? If so, what are some examples from each case? ...

GreaseMonkey script to auto login using HTTP authentication

I've got quite a few GreaseMonkey scripts that I wrote at my work which automatically log me into the internal sites we have here. I've managed to write a script for nearly each one of these sites except for our time sheet application, which uses HTTP authentication. Is there a way I can use GreaseMonkey to log me into this site auto...

Response.StatusCode and Internet Explorer - Display custom message?

I am implementing a HttpRequestValidationException in my Application_Error Handler, and if possible, I want to display a custom message. Now, I'm thinking about the StatusCode. In my current example, it sends a 200, which I think should not be done. I would like to send the (IMHO) more appropriate 400 Bad Request instead. However, at th...

How to write a download progress indicator in Python?

I am writing a little application to download files over http (as, for example, described here). I also want to include a little download progress indicator showing the percentage of the download progress. Here is what I came up with: sys.stdout.write(rem_file + "...") urllib.urlretrieve(rem_file, loc_file, reporthook=dlP...

Browser refresh behaviour

When a user hits Refresh on their browser, it reloads the page but keeps the contents of form fields. While I can see this being a useful default, it can be annoying on some dynamic pages, leading to a broken user experience. Is there a way, in HTTP headers or equivalents, to change this behaviour? ...

How can I perform HTTP PUT uploads to a VMware ESX Server in PowerShell?

VMware ESX, ESXi, and VirtualCenter are supposed to be able to support HTTP PUT uploads since version 3.5. I know how to do downloads, that's easy. I've never done PUT before. Background information on the topic is here: http://communities.vmware.com/thread/117504 ...

Good ways to test a unit that communicates via HTTP

Often, I find myself wanting to write a unit test for a portion of code that accesses HTTP resources as part of its normal function. Have you found any good ways to write these kinds of tests? ...

How can I find the response time of a HTTP request through a Socket

I'm using a Java socket, connected to a server. If I send a HEADER http request, how can I measure the response time from the server? Must I use a provided java timer, or is there an easier way? I'm looking for a short answer, I don't want to use other protocols etc. Obviously do I neither want to have a solution that ties my applicati...

How to get a http file metadata?

How to get a file's creation date or file size, for example this Hello.jpg at http://www.mywebsite.com/now/Hello.jpg(note: This URL does not exist)? The purpose of this question is to make my application re-download the files from the any website when it has detected that the website has an updated version of the files and the files in m...

How to get reliable HTTP messages via Firefox XPCOM in Javascript

Hello, I am trying to program a small server+client in Javascript on Firefox, using XPCOM. To get the HTTP message in Javascript, I am using the nsIScriptableInputStream interface. This f**ing component through the read() method randomly cut the message and I cannot make it reliable. Is anybody know a solution to get reliably the info...