http

HTTP Response Question

Is it valid to return different text in the response header than the usual fare? For example if the request is invalid, could I respond with: HTTP/1.1 400 Here be Dragons And have that header properly handled by proxies, etc? ...

How do I upload binary content from an HTTP post into a MYSQL database through PHP without using PHP's file handling functions?

This may not be possible, but I'd like to ask anyway and see if there's a creative solution out there. I'd like to have a "file" form field on my site that uploads a file into a BLOB field in a MYSQL database. I must use PHP to accomplish this task. Normally, I know you would open the temp file found in the $_FILES array, using fope...

Determine the file size before dowloading data through HTTP

Is this possible to do? I'm currently coding in PHP using cURL library but this rather applies to HTTP as a whole. The most obvious way sounded like throwing a HEAD request to the data URL and read its Content-Length header, but the problem is that some servers including apache 2.0 does not send Content-Length against HEAD requests and ...

What things should be kept in mind while desigining an HTTP based protocol?

I have heard that http is a nice way to design my own protocol. although i can design a binary protocol, i would prefer to follow the HTTP standard to design my protocol. basically the flow of the application is that with the request the client sends some parameter strings to the server, the server sends the response string to the applic...

loading image from URL - How to capture the exception if the image is not there

My problem relates to the other question I have asked about loading image from the URL. The code below works. However, I have encountered the problem if I try to get the image (it suppose be there) but apparently was removed. The application does not know and returns the error. Is there a way to prevent it by capturing incoming error. ...

How does browser know the content type when such header is not specified?

Hello, if the server doesn't send the content-type header, how does the browser tell which kind of content he got? For example, when I get the SO logo with chrome, the image is intact, though the server doesn't state its extension (at least, explicitly) ...

How can I programmatically tell if a binary file on a website (e.g. image) has changed without downloading it?

How can I programmatically tell if a binary file on a website (e.g. image) has changed without downloading it? Is there a way using HTTP methods (in C# in this case) to check prior to fully downloading it? ...

Does a TCP socket connection have a "keep alive"?

I have heard of HTTP keep-alive but for now I want to open a socket connection with a remote server. Now will this socket connection remain open forever or is there a timeout limit associated with it similar to HTTP keep-alive? ...

HTTP persistent connection vs TCP socket connection

From this article on Wikipedia: Keepalive messages were not officially supported in HTTP 1.0. In HTTP 1.1 all connections are considered persistent, unless declared otherwise. Does this mean that using this mechanism I can actually simulate a TCP socket connection? Using this can I make a Server "push" data to a clie...

What exactly does a "persistent connection" mean?

I read about "HTTP persistent connection" but somehow I don't seem to understand what does persistent mean in this context. Could you'll elaborate? ...

HTTP Content-Type header to serve a font file

Hi, I'm making an online EOT converter... What 'Content-Type' header should I set to serve a font file? Thank you. ...

C# code for downloading item, that checks text/binary, and gzip/non-compressed???

Hi, QUESTION: Anyone have some code they could post that will download a file from a URL/Link that will automatically handle: (a) binary or text based (b) gzip encoded BACKGROUND: I've been starting to do this but hitting hurdles. Like I was using WebClient however it seems it can't handle the gzip bit (need to drop back to HTTPWebR...

What is the best way to "fake" DELETE and PUT methods using JAX-RS?

I've just started to use Jersey to create a RESTful API for my site. Its a wonderful change from having to roll my own support for RESTful services in Java. One thing I just can't seem to figure out is how to "fake" a DELETE and PUT method. Jersey supports the annotations @PUT and @DELETE, however many Load-Balancers will not allow th...

How do I do a HTTP GET in Java?

Hello, How do I do a HTTP GET in Java? Thanks. David ...

an auth method over HTTP(s) and/or REST with libraries for Python and/or C++

Because I don't exactly know how any auth method works I want to write my own. So, what I want to do is the following. A client sends over HTTPs username+password(or SHA1(username+password)) the server gets the username+password and generates a big random number and stores it in a table called TOKENS(in some database) along with his IP...

What does a HTTP Request that references a file in the middle of the path?

I'm writting a HTTP server and when i tried the Serendipity PHP Blog i get requests from the browser like this one: GET /serendipity_admin.php/templates/default/admin/pluginmanager.css HTTP/1.1 The "/serendipity_admin.php" file does exist so the "/serendipity_admin.php/templates/default/admin/pluginmanager.css" obviously must fail. W...

What is the purpose of (Apache) putting inode into an ETag?

There are plenty of articles on the web detailing why you might not want to use Apache's default inode-mtime-size format for ETags. But I have yet to read anything on what might have motivated the inclusion of inode for Apache in the first place. On the face of it, it only seems useful if one needs to be able to differentiate between oc...

How can I get the actual error behind HttpResponseException?

I'm using Apache HttpComponents Client to POST to a server that returns JSON. The problem is that if the server returns a 400 error, I seem to have no way of telling what the error was from Java (had to resort to a packet sniffer so far - ridiculous). Here is the code: HttpClient httpclient = new DefaultHttpClient(); params.add(new Basi...

Flex: HTTP request error #2032

In Flex 3 application I use HTTPService class to make requests to the server: var http:HTTPService = new HTTPService(); http.method = 'POST'; http.url = hostUrl; http.resultFormat = 'e4x'; http.addEventListener(ResultEvent.RESULT, ...); http.addEventListener(FaultEvent.FAULT, ...); http.send(params); The application has Comet-architec...

how am I supposed to find out that a form is being submitted twice?

Is something in the http protocol that will help me find out, or should I check the fields by myself. If identical field values can be submitted more than once, should I add a dummy hidden field or something? ...