http

Content-Length header versus chunked encoding

I'm trying to weigh the pros and cons of setting the Content-Length HTTP header versus using chunked encoding to return [possibly] large files from my server. One or the other is needed to be compliant with HTTP 1.1 specs using persistent connections. I see the advantage of the Content-Length header being : Download dialogs can show ...

Malformed HTTP requests on rails?

Hi all, I'm getting this occacional error from my rails app: ActionController::MethodNotAllowed: Only get, put, and delete requests are allowed. I think it's caused by a malformed HTTP request (in this case a DELETE request) caused by the client browser... Maybe? The URL that triggers this action it's like: https://domain.com/resour...

How to correct 404 error with post

System.Net.WebException: The remote server returned an error: (404) Not Found I have three website. also have a method called post. When I post a form to siteB from siteA. the method post working perfect. When I post from siteA to siteC with same method, it give me an error System.Net.WebException: The remote server returned an error: (4...

How to respond to HTTP GET with .net and XML

How to respond to HTTP GET with c#/.net and XML What I am trying to is when another service call posts to a get with say 5 parameters. This service would respond with an appropriate xml file. Is WCF the way to go? Any good examples out there? Is this way easier/faster on some other platform? ...

How to "flush" the response in Pylons (similar to ASP Response.Write)

I have a Pylons controller that is called via jQuery $.ajaxSubmit(). It executes a long-running operation and I want to have it return progress messages before the entire output is available. As a simple proof of concept I've tried this: response.body_file.write('<script>OnExecutionProgress("Starting");</script>\n') time.sleep(2) respon...

Headers to set for AJAX calls in a custom webserver

I'm writing a custom web server. When I enter the URL of my server in the browser, I get the sample text I write out to the socket in my browser correctly. This is the HTTP response that I write: HTTP/1.1 200 OK\r\n Server: My Server\r\n Date: Blah\r\n Content-Type: text/plain\r\n \r\n This is some sample text. This appears in my browse...

[Ruby] Why do I have to URI.encode even safe characters for Net::HTTP requests?

I was trying to send a GET request to Twitter (user ID replaced for privacy reasons) using Net::HTTP: url = URI.parse("http://api.twitter.com/1/friends/ids.json?user_id=12345") resp = Net::HTTP.get_response(url) this throws an exception in Net::HTTP: NoMethodError: undefined method empty?' for #<URI::HTTP:0x59f5c04> from /Sy...

HTTP Error 401.3 for specific .pdf file

Hi all, I just uploaded two .pdf files on my server. They are both in the same folder. The first one can be normally accessed but for the second one I get an HTTP Error 401.3 "You are not authorized to view this page" This looks weird to me. Do you have any idea why is this happening? ...

Asking browsers to cache as aggressively as possible

This is about a web app that serves images. Since the same request will always return the same image, I want the accessing browsers to cache the images as aggressively as possible. I pretty much want to tell the browser Here's your image. Go ahead and keep it; it's really not going to change for the next couple of days. No need to co...

PHP: Cache RSS data to avoid requesting it everytime the page loads.

I'm parsing data from this RSS feed: http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&amp;locCode=SAM|AR|AR005|MONTE%20MAIZ, The data there updates once every hour. To parse it, I load the RSS at the initialization of my class and convert it into an usable object. The problem with this is that every time the page loads, the ...

Using GET instead of POST to delete data behind authenticated pages

I know you should use POST whenever data will be modified on a public website. There are several reasons including the fact that search engines will follow all the links and modify the data. My question is do you think it is OK to use GET behind authenticated pages in something like an admin interface? One example would be a list of pr...

Which HTTP redirect status code is best for this REST API scenario?

I'm working on a REST API. The key objects ("nouns") are "items", and each item has a unique ID. E.g. to get info on the item with ID foo: GET http://api.example.com/v1/item/foo New items can be created, but the client doesn't get to pick the ID. Instead, the client sends some info that represents that item. So to create a new item: P...

Are rails timers reliable when using Net::HTTP?

Hi All. When reading data from a potentially slow website, I want to ensure that get_response can not hang, and so added a timer to timeout after x seconds. So far, so good. I then read http://ph7spot.com/musings/system-timer which illustrates that in certain situations timer.rb doesn't work due to ruby's implementation of threads. Doe...

How can I *prevent* Apache2 from setting the Content-Type header?

I have a CGI script that prints the following on stdout: print "Status: 302 Redirect\n"; print "Server: Apache-Coyote/1.1\n"; print "Location: $redirect\n"; print "Content-Length: 0\n"; print "Date: $date\n\n"; Where $redirect and $date are reasonable values. What Apache2 actually sends also includes a Content-Type: header (text/plain...

Can anyone explain UriMatcher (Android SDK)?

I have been tasked with designing my web services client code to use the utility class UriMatcher in the Android SDK. Unfortunately, the example in the Dev Guide does not relate to anything in my mind. I know I am missing some fundamental points to the functionality and possibly about Uri itself. If you can tie it to some web APIs tha...

Soap, HTTP, .NET, OCX platform for message exchage

Hello, We are entering custom project in which we need to build platform for other programmers in order to communicate with a specific device. This device is to be used on daily basis. We have firmware and RS232 communication protocol with them on very low level. We must ensure .NET, Java and Delphi programmers to access device (send co...

User Agent in http client Android

Hi everybody, I building an Https Client to send some data to a server, but I don't know what to pass in User-Agent. Should I use the webkit one's or do I have to build one explicitely for my App? I'm using this handy post Thanks for any help ...

How do I make a HTTP POST request to an url from within a c++ dll?

Hi, there's an open-source application I need to use. It allows you to use a custom dll. Unfortunately, I can't code c++; i don't like it; it don't want to learn it. I do know PHP very well however, thus you can see that I'll rather do my logic within a PHP application. Thus I'm thinking about posting the data from c++/dll to a url on m...

Send files using Content-Disposition: attachment in parallel

I have a PHP page that sends a file to the browser depending on the request data it receives. getfile.php?get=something sends file A, getfile.php?get=somethingelse sends file B and so on and so forth. This is done like so: header('Content-Disposition: attachment; filename='. urlencode($filename)); readfile($fileURL); It works except i...

Post Redirect Get pattern and use in a RESTful resource-based service when supporting searching

If I have a HTTP based RESTful service and I want to POST a search resource and use the PRG pattern for returning the URL to the search-result resource, I have to persist the search-result resource on the server. Is this a good idea? If I do persist the search-result resource how long is it persisted for? Can I control this by a HTTP ...