hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r159144 - in jakarta/httpclient/trunk/http-common/src/java/org/apache/http: HttpMessage.java HttpMutableMessage.java HttpRequest.java HttpResponse.java impl/BasicHttpMessage.java
Date Sun, 27 Mar 2005 12:53:52 GMT
Author: olegk
Date: Sun Mar 27 04:53:50 2005
New Revision: 159144

URL: http://svn.apache.org/viewcvs?view=rev&rev=159144
Log:
Both HttpRequest and HttpResponse changed to extend a common interface HttpMessage

Added:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMessage.java   (with
props)
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableMessage.java
  (with props)
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpMessage.java
  (with props)
Modified:
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpRequest.java
    jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpResponse.java

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMessage.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMessage.java?view=auto&rev=159144
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMessage.java (added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMessage.java Sun Mar
27 04:53:50 2005
@@ -0,0 +1,53 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public interface HttpMessage {
+
+    boolean containsHeader(String name);
+    
+    Header[] getHeaders(String name);
+
+    Header getFirstHeader(String name);
+
+    Header getLastHeader(String name);
+
+    Header[] getAllHeaders();
+    
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMessage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableMessage.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableMessage.java?view=auto&rev=159144
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableMessage.java
(added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableMessage.java
Sun Mar 27 04:53:50 2005
@@ -0,0 +1,57 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http;
+
+import java.util.Iterator;
+
+import org.apache.http.params.HttpParams;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+public interface HttpMutableMessage extends HttpMessage {
+
+    void addHeader(Header header);
+
+    void setHeader(Header header);
+
+    void removeHeader(Header header);
+    
+    Iterator headerIterator();
+
+    HttpParams getParams();
+    
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpMutableMessage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpRequest.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpRequest.java?view=diff&r1=159143&r2=159144
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpRequest.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpRequest.java Sun Mar
27 04:53:50 2005
@@ -1,5 +1,5 @@
 /*
- * $Header: $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -29,8 +29,6 @@
 
 package org.apache.http;
 
-import org.apache.http.params.HttpParams;
-
 /**
  * <p>
  * </p>
@@ -40,12 +38,8 @@
  * 
  * @since 4.0
  */
-public interface HttpRequest {
+public interface HttpRequest extends HttpMessage {
 
     RequestLine getRequestLine();
-
-    HeaderGroup getHeaders();
-    
-    HttpParams getParams();
     
 }

Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpResponse.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpResponse.java?view=diff&r1=159143&r2=159144
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpResponse.java (original)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/HttpResponse.java Sun Mar
27 04:53:50 2005
@@ -1,5 +1,5 @@
 /*
- * $Header: $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -29,8 +29,6 @@
 
 package org.apache.http;
 
-import org.apache.http.params.HttpParams;
-
 /**
  * <p>
  * </p>
@@ -40,14 +38,10 @@
  * 
  * @since 4.0
  */
-public interface HttpResponse {
+public interface HttpResponse extends HttpMessage {
 
     StatusLine getStatusLine();
 
-    HeaderGroup getHeaders();
-    
     HttpEntity getEntity();
-    
-    HttpParams getParams();
     
 }

Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpMessage.java
URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpMessage.java?view=auto&rev=159144
==============================================================================
--- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpMessage.java
(added)
+++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpMessage.java
Sun Mar 27 04:53:50 2005
@@ -0,0 +1,106 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ *  Copyright 1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl;
+
+import java.util.Iterator;
+
+import org.apache.http.Header;
+import org.apache.http.HeaderGroup;
+import org.apache.http.HttpMutableMessage;
+import org.apache.http.params.HttpParams;
+
+/**
+ * <p>
+ * </p>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ * @version $Revision$
+ * 
+ * @since 4.0
+ */
+class BasicHttpMessage implements HttpMutableMessage {
+    
+    private final HeaderGroup headergroup;
+    private final HttpParams params;
+    
+    protected BasicHttpMessage() {
+        super();
+        this.headergroup = new HeaderGroup();
+        this.params = new DefaultHttpParams(null);
+    }
+
+    public boolean containsHeader(String name) {
+        return this.headergroup.containsHeader(name);
+    }
+    
+    public Header[] getHeaders(final String name) {
+        return this.headergroup.getHeaders(name);
+    }
+
+    public Header getFirstHeader(final String name) {
+        return this.headergroup.getFirstHeader(name);
+    }
+
+    public Header getLastHeader(final String name) {
+        return this.headergroup.getLastHeader(name);
+    }
+
+    public Header[] getAllHeaders() {
+        return this.headergroup.getAllHeaders();
+    }
+    
+    public void addHeader(final Header header) {
+        this.headergroup.addHeader(header);
+    }
+
+    public void setHeader(final Header header) {
+        if (header == null) {
+            return;
+        }
+        Header[] headers = this.headergroup.getHeaders(header.getName());
+        for (int i = 0; i < headers.length; i++) {
+            this.headergroup.removeHeader(headers[i]);
+        }
+        this.headergroup.addHeader(header);
+    }
+
+    public void removeHeader(final Header header) {
+        this.headergroup.removeHeader(header);
+    }
+    
+    public Iterator headerIterator() {
+        return this.headergroup.iterator();
+    }
+    
+    public HttpParams getParams() {
+        return this.params;
+    }
+    
+}

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/impl/BasicHttpMessage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message