SPR-7146 - AppEngine : bug with SimpleClientHttpResponse.getHeaders

master
Arjen Poutsma 15 years ago
parent a910ce68ff
commit f8a05da1c9
  1. 6
      org.springframework.web/src/main/java/org/springframework/http/client/CommonsClientHttpRequestFactory.java
  2. 10
      org.springframework.web/src/main/java/org/springframework/http/client/SimpleClientHttpResponse.java

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,8 +32,8 @@ import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.TraceMethod;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.util.Assert;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
/**
* {@link org.springframework.http.client.ClientHttpRequestFactory} implementation that uses
@ -96,7 +96,7 @@ public class CommonsClientHttpRequestFactory implements ClientHttpRequestFactory
if (timeout < 0) {
throw new IllegalArgumentException("timeout must be a non-negative value");
}
this.httpClient.getHttpConnectionManager().getParams().setSoTimeout(timeout);
getHttpClient().getHttpConnectionManager().getParams().setSoTimeout(timeout);
}

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -54,10 +54,14 @@ final class SimpleClientHttpResponse implements ClientHttpResponse {
public HttpHeaders getHeaders() {
if (this.headers == null) {
this.headers = new HttpHeaders();
// Header field 0 is the status line, so we start at 1
// Header field 0 is the status line for most HttpURLConnections, but not on GAE
String name = this.connection.getHeaderFieldKey(0);
if (StringUtils.hasLength(name)) {
this.headers.add(name, this.connection.getHeaderField(0));
}
int i = 1;
while (true) {
String name = this.connection.getHeaderFieldKey(i);
name = this.connection.getHeaderFieldKey(i);
if (!StringUtils.hasLength(name)) {
break;
}

Loading…
Cancel
Save