use of org.apache.http.message.BasicStatusLine in project android-volley by mcxiaoke.
the class MockHttpClient method execute.
// This is the only one we actually use.
@Override
public HttpResponse execute(HttpUriRequest request, HttpContext context) {
requestExecuted = request;
StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), mStatusCode, "");
HttpResponse response = new BasicHttpResponse(statusLine);
response.setEntity(mResponseEntity);
return response;
}
use of org.apache.http.message.BasicStatusLine in project android-uploader by nightscout.
the class AbstractRestUploaderTest method setUpExecuteCaptor.
public void setUpExecuteCaptor(int status) throws IOException {
HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("mock", 1, 2), status, ""));
response.setEntity(new StringEntity(""));
when(mockHttpClient.execute(captor.capture())).thenReturn(response);
}
use of org.apache.http.message.BasicStatusLine in project android-uploader by nightscout.
the class RestLegacyUploaderTest method setUpExecuteCaptor.
public void setUpExecuteCaptor(int status) throws IOException {
captor = ArgumentCaptor.forClass(HttpUriRequest.class);
HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("mock", 1, 2), status, ""));
response.setEntity(new StringEntity(""));
when(mockHttpClient.execute(captor.capture())).thenReturn(response);
}
use of org.apache.http.message.BasicStatusLine in project robovm by robovm.
the class DefaultHttpResponseFactory method newHttpResponse.
// non-javadoc, see interface HttpResponseFactory
public HttpResponse newHttpResponse(final ProtocolVersion ver, final int status, HttpContext context) {
if (ver == null) {
throw new IllegalArgumentException("HTTP version may not be null");
}
final Locale loc = determineLocale(context);
final String reason = reasonCatalog.getReason(status, loc);
StatusLine statusline = new BasicStatusLine(ver, status, reason);
return new BasicHttpResponse(statusline, reasonCatalog, loc);
}
use of org.apache.http.message.BasicStatusLine in project LiveSDK-for-Android by liveservices.
the class ApiTest method loadPathInvalidResponse.
/**
* Loads an invalid path response into the HttpClient.
*
* @param requestPath
* @throws Exception
*/
protected void loadPathInvalidResponse(String requestPath) throws Exception {
JSONObject error = new JSONObject();
error.put(JsonKeys.CODE, ErrorCodes.REQUEST_URL_INVALID);
String message = String.format(ErrorMessages.URL_NOT_VALID, requestPath.toLowerCase());
error.put(JsonKeys.MESSAGE, message);
JSONObject response = new JSONObject();
response.put(JsonKeys.ERROR, error);
byte[] bytes = response.toString().getBytes();
this.mockResponse.addHeader(HTTP.CONTENT_LEN, Long.toString(bytes.length));
this.mockEntity.setInputStream(new ByteArrayInputStream(bytes));
StatusLine status = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_BAD_REQUEST, "Bad Request");
this.mockResponse.setStatusLine(status);
this.mockClient.setHttpResponse(this.mockResponse);
}
Aggregations