public ErrorUnmarshallingHandler(PutMediaResponseHandler responseHandler, HttpResponseHandler<AmazonServiceException> errorResponseHandler, Request<?> request) { this.responseHandler = responseHandler; this.errorResponseHandler = errorResponseHandler; // Eagerly create the error response to serve as a container for dumping HTTP data into this.errorResponse = new com.amazonaws.http.HttpResponse(request, null); }
/** * Creates and initializes an HttpResponse object suitable to be passed to an HTTP response * handler object. * * @param request Marshalled request object. * @param method The HTTP method that was invoked to get the response. * @param context The HTTP context associated with the request and response. * @return The new, initialized HttpResponse object ready to be passed to an HTTP response * handler object. * @throws IOException If there were any problems getting any response information from the * HttpClient method object. */ public static HttpResponse createResponse(Request<?> request, HttpRequestBase method, org.apache.http.HttpResponse apacheHttpResponse, HttpContext context) throws IOException { HttpResponse httpResponse = new HttpResponse(request, method, context); if (apacheHttpResponse.getEntity() != null) { httpResponse.setContent(apacheHttpResponse.getEntity().getContent()); } httpResponse.setStatusCode(apacheHttpResponse.getStatusLine().getStatusCode()); httpResponse.setStatusText(apacheHttpResponse.getStatusLine().getReasonPhrase()); for (Header header : apacheHttpResponse.getAllHeaders()) { httpResponse.addHeader(header.getName(), header.getValue()); } return httpResponse; }
/** * Builds an instance of {@link HttpResponse} * * @return a new instance of {@link HttpResponse} */ public HttpResponse build() { return new HttpResponse(statusText, statusCode, Collections.unmodifiableMap(headers), content); } }
/** * Creates and initializes an HttpResponse object suitable to be passed to an HTTP response * handler object. * * @param request Marshalled request object. * @param method The HTTP method that was invoked to get the response. * @param context The HTTP context associated with the request and response. * @return The new, initialized HttpResponse object ready to be passed to an HTTP response * handler object. * @throws IOException If there were any problems getting any response information from the * HttpClient method object. */ public static HttpResponse createResponse(Request<?> request, HttpRequestBase method, org.apache.http.HttpResponse apacheHttpResponse, HttpContext context) throws IOException { HttpResponse httpResponse = new HttpResponse(request, method, context); if (apacheHttpResponse.getEntity() != null) { httpResponse.setContent(apacheHttpResponse.getEntity().getContent()); } httpResponse.setStatusCode(apacheHttpResponse.getStatusLine().getStatusCode()); httpResponse.setStatusText(apacheHttpResponse.getStatusLine().getReasonPhrase()); for (Header header : apacheHttpResponse.getAllHeaders()) { httpResponse.addHeader(header.getName(), header.getValue()); } return httpResponse; }
public ErrorUnmarshallingHandler(PutMediaResponseHandler responseHandler, HttpResponseHandler<AmazonServiceException> errorResponseHandler, Request<?> request) { this.responseHandler = responseHandler; this.errorResponseHandler = errorResponseHandler; // Eagerly create the error response to serve as a container for dumping HTTP data into this.errorResponse = new com.amazonaws.http.HttpResponse(request, null); }
/** * Builds an instance of {@link HttpResponse} * * @return a new instance of {@link HttpResponse} */ public HttpResponse build() { return new HttpResponse(statusText, statusCode, Collections.unmodifiableMap(headers), content); } }
/** * Builds an instance of {@link HttpResponse} * * @return a new instance of {@link HttpResponse} */ public HttpResponse build() { return new HttpResponse(statusText, statusCode, Collections.unmodifiableMap(headers), content); } }
/** * Creates and initializes an HttpResponse object suitable to be passed to an HTTP response * handler object. * * @param method The HTTP method that was invoked to get the response. * @param context The HTTP context associated with the request and response. * @return The new, initialized HttpResponse object ready to be passed to an HTTP response * handler object. * @throws IOException If there were any problems getting any response information from the * HttpClient method object. */ private HttpResponse createResponse(HttpRequestBase method, org.apache.http.HttpResponse apacheHttpResponse, HttpContext context) throws IOException { HttpResponse httpResponse = new HttpResponse(request, method, context); if (apacheHttpResponse.getEntity() != null) { httpResponse.setContent(apacheHttpResponse.getEntity().getContent()); } httpResponse.setStatusCode(apacheHttpResponse.getStatusLine().getStatusCode()); httpResponse.setStatusText(apacheHttpResponse.getStatusLine().getReasonPhrase()); for (Header header : apacheHttpResponse.getAllHeaders()) { httpResponse.addHeader(header.getName(), header.getValue()); } return httpResponse; }
@Benchmark public Object getItem(GetItemState s) { HttpResponse resp = new HttpResponse(null, null); resp.setContent(new ByteArrayInputStream(s.testItem.utf8())); try { return getItemJsonResponseHandler().handle(resp); } catch (Exception e) { throw new RuntimeException(e); } }
private void execRequest(String endpoint, int status) { AWSRequestMetrics metrics = new AWSRequestMetricsFullSupport(); metrics.addProperty(AWSRequestMetrics.Field.ServiceName, "AmazonCloudWatch"); metrics.addProperty(AWSRequestMetrics.Field.ServiceEndpoint, endpoint); metrics.addProperty(AWSRequestMetrics.Field.StatusCode, "" + status); if (status == 503) { metrics.addProperty(AWSRequestMetrics.Field.AWSErrorCode, "Throttled"); } String counterName = "BytesProcessed"; String timerName = "ClientExecuteTime"; metrics.setCounter(counterName, 12345); metrics.getTimingInfo().addSubMeasurement(timerName, TimingInfo.unmodifiableTimingInfo(100000L, 200000L)); Request<?> req = new DefaultRequest(new ListMetricsRequest(), "AmazonCloudWatch"); req.setAWSRequestMetrics(metrics); req.setEndpoint(URI.create(endpoint)); HttpResponse hr = new HttpResponse(req, new HttpPost(endpoint)); hr.setStatusCode(status); Response<?> resp = new Response<>(null, new HttpResponse(req, new HttpPost(endpoint))); collector.collectMetrics(req, resp); }
@Override public DescribeStreamResult describeStream(String streamName, String exclusiveStartShardId) { int nextShardId = 0; if (exclusiveStartShardId != null) { nextShardId = parseInt(exclusiveStartShardId) + 1; } boolean hasMoreShards = nextShardId + 1 < shardedData.size(); List<Shard> shards = new ArrayList<>(); if (nextShardId < shardedData.size()) { shards.add(new Shard().withShardId(Integer.toString(nextShardId))); } HttpResponse response = new HttpResponse(null, null); response.setStatusCode(200); DescribeStreamResult result = new DescribeStreamResult(); result.setSdkHttpMetadata(SdkHttpMetadata.from(response)); result.withStreamDescription( new StreamDescription() .withHasMoreShards(hasMoreShards) .withShards(shards) .withStreamName(streamName)); return result; }