hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Httpcomponents Wiki] Trivial Update of "GeneralHttpCoreIntroduction" by QuintinBeukes
Date Mon, 16 Jun 2008 12:11:07 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Httpcomponents Wiki" for change notification.

The following page has been changed by QuintinBeukes:
http://wiki.apache.org/HttpComponents/GeneralHttpCoreIntroduction

The comment on the change is:
Removed ! in front of HC NikiNames to create pages for them.

------------------------------------------------------------------------------
  Interceptors are called in the order they were added to the processor, in each 
  respective phase of the connection (before/after you execute the request). 
  To create your own interceptors you simple need to override either 
- !HttpRequestInterceptor or !HttpResponseInterceptor and add an 
+ HttpRequestInterceptor or HttpResponseInterceptor and add an 
  instance of your class to your processor.
  
  There are 2 required request interceptors, and 3 required response interceptors.
- You need to add these to have !HttpCore work correctly. There are no limits to the
+ You need to add these to have HttpCore work correctly. There are no limits to the
  amount you can add after this.
  
  Later I will demonstrate implementing a custom interceptor by creating a response 
  interceptor that modifies all HTML documents retrieved by adding a special header
  to the response. It's purpose is useless, but demonstrates it's purposes.  
  
- Next up is the !HttpRequestExecutor, a very simple object, and the connection manager. 
+ Next up is the HttpRequestExecutor, a very simple object, and the connection manager. 
- Basically the !HttpRequestExecutor is just a utility class for executing the separate 
+ Basically the HttpRequestExecutor is just a utility class for executing the separate 
  steps of the request, specifically the interceptors and the request itself. The
  connection manager is a class we will be making later to manage the persistent
  or keep-alive connections and their sockets. HttpCore doesn't have any built in 
@@ -131, +131 @@

  classes.
  
  The context is configured by setting attributes with the void setAttribute(String id, Object
obj)
- method. Ids for context attributes are defined in the !ExecutionContext class, and
+ method. Ids for context attributes are defined in the ExecutionContext class, and
  each attribute takes a class as a value. Attribute names take the form of
- property names, and the !ExecutionContext constants are simply String objects
+ property names, and the ExecutionContext constants are simply String objects
  creating an abstraction over these property names.
  
  {{{#!java numbers=off
@@ -202, +202 @@

  represents a host for an HTTP connection, it can take one extra parameter, which
  is the scheme. If you would be using SSL/TLS, you would set the scheme to "https".
  The default scheme is "http", and sufficient for our current class. Also, not all
- places where !HttpHost is accepted use the scheme. The parameter is present, but used
+ places where HttpHost is accepted use the scheme. The parameter is present, but used
  only where the implementation requires this information. More on this later.
  
- Again we set the !ExecutionContext.HTTP_TARGET_HOST context attribute (http.target_host),

+ Again we set the ExecutionContext.HTTP_TARGET_HOST context attribute (http.target_host),

- which takes an !HttpHost object as value.
+ which takes an HttpHost object as value.
  
  {{{#!java numbers=off
      // fetch a connection from the connection manager
@@ -243, +243 @@

  
  As you can see here, we run the interceptors before and after we execute the
  request. This is done with the httpExecutor.preProcess(...) and httpExecutor.postProcess(...)
- methods. It also becomes obvious here why I referred to the !HttpExecutor class as
+ methods. It also becomes obvious here why I referred to the HttpExecutor class as
  a utility class, and why you only need one to share between all your request
  instances. It doesn't store any request specified information, but merely
  uses the objects supplied to each of it's methods to execute the relevant step
- of the HTTP request. The !HttpContext class is used by !HttpExecute to store
+ of the HTTP request. The HttpContext class is used by HttpExecute to store
  instance type information.
  
  After we finished the complete execution procedure, we can store the input stream
@@ -255, +255 @@

  first explain the entity.
  
  == HttpEntity ==
- A body of content in !HttpCore/HttpClient is represented by the !HttpEntity class.
+ A body of content in HttpCore and HttpClient is represented by the HttpEntity class.
  Whether it's a body received from a response, or a body sent by a request (POST/PUT),
- the !HttpEntity is your friend.
+ the HttpEntity is your friend.
  
- !HttpEntity has a few methods for retrieving the length of the content (when available),
+ HttpEntity has a few methods for retrieving the length of the content (when available),
  the encoding, and some information like whether it's chunked/repeatable and so on.
  
  For this guide we will only be discussing response entities. To retrieve the content
- from these entities you retrieve the !InputStream object with the !HttpEntity.getContent()
+ from these entities you retrieve the InputStream object with the HttpEntity.getContent()
  method. 
  
- The !EntityUtils class has 4 static utility methods for dealing with entity objects.
+ The EntityUtils class has 4 static utility methods for dealing with entity objects.
  Three of these are used to consume the whole stream and store it in either a byte array
  or a String. This is an example of their use:
  
@@ -395, +395 @@

  [http://hc.apache.org/httpcomponents-core/httpcore/apidocs/index.html API documentation].
  
  == Simple Connection Manager ==
- Before we can run our !HttpCore class, we need to complete the last step, which is
+ Before we can run our HttpCore class, we need to complete the last step, which is
  to make the connection manager.
  
- !HttpCore has no connection management, which makes it very flexible, as the connection
+ HttpCore has no connection management, which makes it very flexible, as the connection
  management is purely left to you, and no limits are placed as to how you have to
  do this. You need to create the connection yourself and specify the socket this 
  connection uses. The flexibility comes in where you can use any network connection 
- methods, as long as you supply a java.net.Socket object to !HttpCore's connection
+ methods, as long as you supply a java.net.Socket object to HttpCore's connection
  wrapper.
  
  To learn more about the connection management design in HttpComponents, specifically HttpClient,
see ClientConnectionManagementDesign.
@@ -513, +513 @@

  MAX_PERSISTENT_REQUESTS constant. 
  
  This isn't ideal, but sufficient for focusing on demonstrating the basic usage of 
- !HttpCore. Later we will build around these weaknesses, making it a stronger, more
+ HttpCore. Later we will build around these weaknesses, making it a stronger, more
  reliable manage.
  
- The manager is constructed by supplying the !HttpParams object used by the request. 
+ The manager is constructed by supplying the HttpParams object used by the request. 
  To create a new connection we supply the URL we want to fetch. This is used
  to retrieve the hostname/port we wish to connect to. From here we check to see
  if our list has one that isn't in use and return it. If there is no such connection
@@ -585, +585 @@

  }}}
  
  Just a note on the buffer size I use to read the input stream. It's important to
- not pick a too large buffer size, as !InputStreams are blocked IO. To put this more
+ not pick a too large buffer size, as InputStreams are blocked IO. To put this more
  clearly, if you pick a buffer size of 10kb, but it's a 1kb/s connection, then you
  will block for 10 seconds on every read. Making a small buffer size allows you 
  to write to the output stream/handle the data as these little bits of data become 
@@ -614, +614 @@

  for too long.
  
  Authentication, SSL, thread safety, built in cache and much more. The idea behind 
- these guides is to run through miscellaneous ideas surrounding !HttpCore, to basically 
+ these guides is to run through miscellaneous ideas surrounding HttpCore, to basically 
  demonstrate the different parts of it while also giving useable examples.
  
- Many others, the developers and myself are available on the !HttpComponents users mailing

+ Many others, the developers and myself are available on the HttpComponents users mailing

  list for any questions or guidance you might have.
  
  Hope this guide was helpful.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message