Showing posts with label http. Show all posts
Showing posts with label http. Show all posts

Tuesday, June 16, 2009

Abdera Client - Using teardown()

I was working on a program which makes several requests to Abdera back end from the client. The client was designed to use a new AbderaClient per request and teardown method was not used on AbderaClient instance after using.

This led to an exception when I run it concurrently (by using about 100 threads). AbderaClient uses HTTPClient and MultiThreadedHttpConnectionManager. Teardown method is the one who shuts down this connection manager and the best practice is to call teardown after using AbderaClient instance.
AbderaClient abderaClient = new AbderaClient(new Abdera());
// make the call
abderaClient.teardown();

Sharing a single instance of AbderaClient among all request is another option but some times it goes to a deadlock state (keeping a connection open for a long time is not recommended anyway).

Wednesday, January 28, 2009

IE6 Doesn't Support application/atom+xml Mime Type

Internet Explorer 6 is having a problem with displaying atom feed documents which's mime type is "application/atom+xml". The browser attempts to download the file instead of rendering it. Simply this happens because browser does not accept or recognize the mime type.

A simple hack can be done to avoid this issue from the server side. That is changing the mime type to appication/xml or text/plain, only if the user agent is IE6 in the HTTP header. Changing the mime type will not fix the problem but at least the browser will display the raw XML content.

The back end application or the server can be configured to send the correct mime type to the relevant browser by looking at the User-Agent header in the HTTP request.

Thursday, October 30, 2008

How to Telnet to a Web Server - HTTP Requests through Telnet

A web server, responding to a HTTP GET request sends the required content to the client. Normally we don't see what is sent between the web client and the server. However we can easily see what is sent by the server by telneting to that web server.

To connect to the web server - open a command line and type the command
telnet host port
eg. telnet www.wso2.com 80

Then you'll get connected to the particular web server and then you can enter any HTTP command you want such as GET, HEAD.

If you need to request for a web page from the web server you can type the HTTP request as follows.

GET pageName HTTP/1.0
eg. GET /products HTTP/1.0

Hit enter twice. Then you will get a response (if page exists)as follows.

HTTP/1.0 200 OK
Date: Thu, 30 Oct 2008 18:17:16 GMT
Server: Apache/2.2.9
X-Powered-By: PHP/5.2.6
Set-Cookie: PHPSESSID=5322082bf473207961031e3df1f45a22; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Pingback: http://wso2.com/xmlrpc.php
Connection: close
Content-Type: text/html; charset=UTF-8

content goes here

.
.
.


You'll get a 404 status if page not found, 301 if the page is moved permanently and 401 if you are not authorized to access the page. More HTTP status codes can be found here.

You can follow a similar way to issue other HTTP commands with the relevant content.
Related Posts with Thumbnails