1 /* 2 * Copyright (C) 2011 The Android Open Source Project 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 com.android.volley; 18 19 import org.apache.http.HttpStatus; 20 21 import java.util.Collections; 22 import java.util.Map; 23 24 /** 25 * Data and headers returned from {@link Network#performRequest(Request)}. 26 */ 27 public class NetworkResponse { 28 /** 29 * Creates a new network response. 30 * @param statusCode the HTTP status code 31 * @param data Response body 32 * @param headers Headers returned with this response, or null for none 33 * @param notModified True if the server returned a 304 and the data was already in cache 34 */ NetworkResponse(int statusCode, byte[] data, Map<String, String> headers, boolean notModified)35 public NetworkResponse(int statusCode, byte[] data, Map<String, String> headers, 36 boolean notModified) { 37 this.statusCode = statusCode; 38 this.data = data; 39 this.headers = headers; 40 this.notModified = notModified; 41 } 42 NetworkResponse(byte[] data)43 public NetworkResponse(byte[] data) { 44 this(HttpStatus.SC_OK, data, Collections.<String, String>emptyMap(), false); 45 } 46 NetworkResponse(byte[] data, Map<String, String> headers)47 public NetworkResponse(byte[] data, Map<String, String> headers) { 48 this(HttpStatus.SC_OK, data, headers, false); 49 } 50 51 /** The HTTP status code. */ 52 public final int statusCode; 53 54 /** Raw data from this response. */ 55 public final byte[] data; 56 57 /** Response headers. */ 58 public final Map<String, String> headers; 59 60 /** True if the server returned a 304 (Not Modified). */ 61 public final boolean notModified; 62 }