android.libraries.volley.request.getrequest.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
package {{invokerPackage}}.request;
import com.android.volley.AuthFailureError;
import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class GetRequest extends StringRequest{
Map apiHeaders;
String contentType;
public GetRequest(String url, Map apiHeaders, String contentType, Response.Listener listener, Response.ErrorListener errorListener) {
super(Method.GET, url, listener, errorListener);
this.apiHeaders = apiHeaders;
this.contentType = contentType;
}
/* (non-Javadoc)
* @see com.android.volley.Request#getHeaders()
*/
@Override
public Map getHeaders() throws AuthFailureError {
Map headers = super.getHeaders();
if (headers == null || headers.equals(Collections.emptyMap())) {
headers = new HashMap();
}
if (apiHeaders != null && !apiHeaders.equals(Collections.emptyMap())) {
headers.putAll(apiHeaders);
}
if(contentType != null) {
headers.put("Content-Type", contentType);
}
return headers;
}
}