Home | History | Annotate | Download | only in http
      1 /*
      2  * Copyright 2008 Netflix, Inc.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *     http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package net.oauth.http;
     18 
     19 import java.io.IOException;
     20 import java.net.URL;
     21 import java.util.Map;
     22 
     23 /**
     24  * An HTTP response.
     25  *
     26  * @author John Kristian
     27  * @hide
     28  */
     29 public abstract class HttpResponseMessage extends HttpMessage {
     30 
     31     protected HttpResponseMessage(String method, URL url) {
     32         super(method, url);
     33     }
     34 
     35     @Override
     36     public void dump(Map<String, Object> into) throws IOException {
     37         super.dump(into);
     38         into.put(STATUS_CODE, Integer.valueOf(getStatusCode()));
     39         String location = getHeader(LOCATION);
     40         if (location != null) {
     41             into.put(LOCATION, location);
     42         }
     43     }
     44 
     45     public abstract int getStatusCode() throws IOException;
     46 
     47     /** The name of a dump entry whose value is the response Location header. */
     48     public static final String LOCATION = "Location";
     49 
     50     /** The name of a dump entry whose value is the HTTP status code. */
     51     public static final String STATUS_CODE = "HTTP status";
     52 
     53     /** The statusCode that indicates a normal outcome. */
     54     public static final int STATUS_OK = 200;
     55 
     56     /** The standard end-of-line marker in an HTTP message. */
     57     public static final String EOL = "\r\n";
     58 
     59 }
     60