>>> import httplib
>>> conn = httplib.HTTPConnection("www.google.com")
>>> conn.request("HEAD", "/index.html")
>>> res = conn.getresponse()
>>> print res.status, res.reason
200 OK
This code will get the HTTP status code. However, notice that I split up "google.com" and "/index.html" on 2 lines.
And it's confusing.
What if I want to ...
I'm developing a front-end to a Rails application. In cross-browser testing, I immediately discovered that Internet Explorer (apparently all modern versions, but at least IE 7 and IE 8) is not correctly interpreting a file I'm trying to load via AJAX (with jQuery) as JavaScript. A file download warning appears and the user needs to confi...
I am returning a stream in some response setting the appropriate content-type header. The behavior i'm looking for is this:
If the browser is able to render content of the given content-type then it should display it in the browser window.
If the browser doesn't know how to render the content then it should display the saveas dialog wh...
How do I get a WCF client to process server responses which have been GZipped or Deflated by IIS?
On IIS, I've followed the instructions here on how to make IIS 6 gzip all responses (where the request contained "Accept-Encoding: gzip, deflate") emitted by .svc wcf services.
On the client, I've followed the instructions here and here on...
Hi.
I am trying to get the full path from the client for files
that are submitted for upload.
I want something like:
C://this/is/your/file.jpg
But, when I try:
m_File = Request.Files[i];
m_File.FileName
I get "just" the file name.
And, when I try:
System.IO.Path.GetFileName(m_File.FileName)
I get a path that seems to p...
I have a J2EE webapp which is used to download a generated PDF served by an HTTP servlet. When running over SSL in production the users are getting the error message
There was an error opening this document. The file cannot be found.
in Acrobat when they choose to open the file in the browser instead of saving it to file. If they ...
Hi,
The application I'm working on at the moment has a session timeout value. If the user hasn't interacted for longer than this value, the next page they try to load, they will be prompted to log in.
All requests made are routed through this mechanism, which includes AJAX calls. Originally we were sending a 200 header with the login p...
Hello, I have this php cURL function:
function curl_login($url,$data,$proxy,$proxystatus){
$fp = fopen("cookietlt.txt", "w");
fclose($fp);
$login = curl_init();
curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MS...
I notice that sometimes audio files on the internet have a "fake" URL.
http://garagaeband.com/3252243
And this will 302 to the real URL:
http://garageband.com/michael_jackson4.mp3
My question is...when supplied with the fake URL, how can you get the REAL URL from headers?
Currently, this is my code for reading the headers of a f...
Hey all.
Right, my problem is that I need to replace an image that appears on every page of a site, which is fine, the problem is I want every user to see the new image and not a cached version of the old one. This is made especially difficult because I can’t make any code changes (far too many places to do it for it to be viable) so I...
How can I set HTTP headers in my firefox extension?
I'll make it so these are only sent while hitting my site so I can detect if the plugin is installed or not and not promote the plugin if it is.
Thanks!
...
Hi all,
I have got a PDF fle which i would like my users to download when they click on a button/link/image.Is this possible?
Thank You
...
I need to suppress an already set session cookie header, but I cannot find any way to do this.
Why?
I need to make an image, sent by a PHP script, cacheable by the end user; this image is used to track if a newsletter has been read by the receiver, so if the image is requested I know the newsletter has been read. I only need to know whe...
We are creating a large secure back office web application in ASP.NET. All access to the site is over https connections, and we'd like to either turn off caching for pages or set caches to expire quickly.
However, the site uses quite a few images and largish javascript files/libraries. Is there a way to selectively cache certain fil...
Hi,
I'm trying to work out the algorithm to tell if non-binary files on the web have changed or not. I was going to go with:
LastModified datetime from header, and then if these aren't present fallback to
ContentLength from header
I'm finding however that for alot of websites the LastModified for the HTML pages are actually just...
I'm trying to serve up png images from a Linux (c++ / Qt4.5.x) server daemon to an iPhone application that is using the Three20 framework - specifically I want to use the TTThumbsViewController view.
I managed to make any web browser view images with the following returned in my daemon when it "GET"s a request:
QTextStream os(socket);
...
I have some static content on my web site that I have set up caching for (using Asp.NET MVC). According to Firebug, the first time I open the page, Firefox sends this request:
GET /CoreContent/Core.css?asm=0.7.3614.34951
Host: 127.0.0.1:3916
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3...
Hi,
Q1 - Is this a bug in .net, or is the webserver I'm using for testing ( Mongoose ) not server up the header field Last-Modified in the format it should?
So in C# VS2008 if I make the call:
response = (HttpWebResponse)request.GetResponse();
Console.Out.WriteLine(" - LM = " + response.LastModified);
I get: ProtocolViolationExceptio...
I'd like to run checks to see if a given URL is registered or not. As a simple proxy for testing if it's registered, I was going to check HTML response codes. 200, 300 probably == registered, 4xx probably == not registered.
I understand that there might be holes in this logic. My question is if cURL has a way to return the HTML response...
I have to pass a meta-information in my HTTP response so I figured out that I could use the response header, for instance "X-MyData: 123456". Is that safe? I mean, there is a possibility that a client proxy remove this header?
Thanks!
...