http

REST API error return good practices

I'm looking for guidance on good practices when it comes to return errors from a REST API. I'm working on a new API so I can take it any direction right now. My content type is XML at the moment, but I plan to support JSON in future. I am now adding some error cases, like for instance a client attempts to add a new resource but has exce...

HTTP Book Recommendation?

The more I see and use REST, the more it seems to be a re-iteration of the ideas behind HTTP. There are many books that talk about REST - what about HTTP? What's the best book on the ideas and technical details behind HTTP itself? ...

Built-in methods to construct a POST request body in .NET?

I am looking for a built-in utility method in .NET for constructing HTTP POST message body for the two common content types: application/x-www-form-urlencoded multipart/form-data I'd rather use someone else's ready and tested implementation than roll my own, even though I realise it's not difficult to do so. However there doesn't see...

How to use the POST command to send a file ?

I would like to send a file using the POST command available on almost all linuxes which include Perl. I'm wondering how.. i would like to do something like : linux:currentdir/$ POST http://www.example.com/upload.php > myFileToUpload I guess i had probably to encode the file, i'm right, it's in base64 ? Isn't it ? I also read in th...

Response does not start with HTTP

Attached Firefox to fiddler and got following error. What would cause this error? Interesting thing to note is that the HTTP header is getting rendered on the page So Fiddler says that there is a protocol violation because response does not start with HTTP. But the HTTP response is rendered on page. ...

Custom simple Python HTTP server not serving css files.

Hello, I had found written in python, a very simple http server, it's do_get method looks like this: def do_GET(self): try: self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers(); filepath = self.path print filepath, USTAW['rootwww'] ...

ASP.Net: HTTP 400 Bad Request error when trying to process http://localhost:5957/http://yahoo.com

I'm trying to create something similar to the diggbar : http://digg.com/http://cnn.com I'm using Visual Studio 2010 and Asp Development server. However, I can't get the ASP dev server to handle the request because it contains "http:" in the path. I've tried to create an HTTPModule to rewrite the URL in the BeginRequest , but the eve...

Nested model parameters during an HTML post

I'm been playing with calling my rails controller using an HTTP POST. I can get it to work with a curl command such as this, given a model named item and an attribute in that item called name: curl -X POST -d "<item><name>myname</name></item>" -H "Content-Type: text/xml" http://localhost:3000/items.xml What I'm curious about is how t...

calling a web service using WCF over Http and Https

I know little about WCF so please bear with me! In our project we have a java web service that runs over http and https. We want to use http internally and https for the external version of our web app. So we've created the proxy class in our application and we have setup the binding for http in the web/app.config and all works fine. ...

How can I set an HTTP Proxy (WebProxy) on a WCF client-side Service proxy?

How can I set the HTTP proxy programmatically, on a WCF client, without using the default proxy? Proxies, proxies, proxies. According to the WCF model of development, I generate client-side "proxy" classes by running svcutil.exe on the WSDL for the service. (This also produces a client-side config file). In my code I new-up an ins...

Event Loop vs Multithread blocking IO

I was reading a comment about server architecture. http://news.ycombinator.com/item?id=520077 In this comment, the person says 3 things: The event loop, time and again, has been shown to truly shine for a high number of low activity connections. In comparison, a blocking IO model with threads or processes has been shown, time and ag...

Hidden features of HTTP

What hidden features of HTTP do you think are worth mentioning? By hidden features I mean features that already are part of the standard but widely rather unknown or unused. Just one feature per answer please. ...

Serving gzipped content from django

I'm trying to serve a gzipped version of a text/html page in Django, but Firefox is telling me there's a content encoding error. NOTES: I realize this is not a best practice and I'm most likely going to use mod_gzip. This is just a learning exercise to understand what's going on. I know about the Django gzip middleware-- it has probl...

HTTP forms using raw PHP

My initial strategy at developing forms was like this: the form post back to the same page and in the page handler I start by looking for POST variables and taking appropriate actions, then display the page content. It was all looking rosy in the beginning. I would place a hidden field inside my form and the page to keep track of current...

How to send a GET request from PHP?

I'm planning to use PHP for a simple requirement. I need to download a XML content from a URL, for which I need to send HTTP GET request to that URL. How do I do it in PHP? ...

Multipart File Upload in Ruby

I simply want to upload an image to a server with POST. As simple as this task sounds, there seems to be no simple solution in Ruby. In my application I am using WWW::Mechanize for most things so I wanted to use it for this too, and had a source like this: f = File.new(filename, File::RDWR) reply = agent.post( 'http://rest-test.her...

Sending info with a HTTP redirect that the browser should send to the redirected location?

Is this possible.. for example, imagine I respond to a request with a 302 (or 303), and I inform the browser to do a request to a given location.. is there a header that I can send with the HTTP 302, so that the subsequent request from the browser would include that header? I know I could do this with the location header, as in redirect...

CFNetwork HTTP timeout?

I am looking for a way to add a timeout to a CFHTTP request. It seems like there should be a feature of the CFHTTPMessage or the CFReadStream object, but I can't find it. Do I have to roll my own timer on the run loop or something? (if so, any code for this?) Thanks! ...

Making a plain ASCII/UTF-8 request/stream HTTP POST request in Python?

I'm reading some documentation on a service I'm trying to use, and it reads something like this: All requests must be sent using HTTP Post. The XML engine only accepts plain ASCII (text) UTF-8 requests/streams. Encoded streams are not acceptable. All requests/responses are XML. But I really just don't understand what it's a...

How do I make an asynchronous GET request in PHP?

Hello all, I wish to make a simple GET request to another script on a different server. How do I do this? In one case, I just need to request an external script without the need for any output. make_request('http://www.externalsite.com/script1.php?variable=45'); //example usage In the second case, I need to get the text output. $o...