Revision: 4647 http://sourceforge.net/p/vexi/code/4647 Author: mkpg2 Date: 2014-02-04 08:15:12 +0000 (Tue, 04 Feb 2014) Log Message: ----------- Update apache http. 4.1.1->4.3.2 - make use of new system settings support which should pick up the proxy settings from the browser (normally) - update fixed code/tidied it up somewhat
Modified Paths: -------------- branches/vexi3/org.vexi-core.download/build.xml branches/vexi3/org.vexi-core.download/meta/product-assembly.xml branches/vexi3/org.vexi-library.net/meta/module.xml branches/vexi3/org.vexi-library.net/src/main/jpp/org/ibex/net/ApacheHTTP.jpp Property Changed: ---------------- trunk/_ebuild/ Modified: branches/vexi3/org.vexi-core.download/build.xml =================================================================== --- branches/vexi3/org.vexi-core.download/build.xml 2014-01-30 08:06:18 UTC (rev 4646) +++ branches/vexi3/org.vexi-core.download/build.xml 2014-02-04 08:15:12 UTC (rev 4647) @@ -1,6 +1,7 @@ -<project default="eclipse_setup"> +<project default="build_release"> <property name="ebuild.home" location="../_ebuild"/> + <property name="project-dir" location="../org.vexi-core.download"/> <import file="${ebuild.home}/interface/workspace.ent"/> </project> \ No newline at end of file Modified: branches/vexi3/org.vexi-core.download/meta/product-assembly.xml =================================================================== --- branches/vexi3/org.vexi-core.download/meta/product-assembly.xml 2014-01-30 08:06:18 UTC (rev 4646) +++ branches/vexi3/org.vexi-core.download/meta/product-assembly.xml 2014-02-04 08:15:12 UTC (rev 4647) @@ -29,7 +29,7 @@ <include source="local" name="core.devtools" conf="devtools"/> <!-- HACK/WORKAROUND should not have to include version here (duplicated with module) SHOULD instead be able to select a module dependency by pattern --> - <include source="maven-public" org="org.apache.httpcomponents" name="httpclient" conf="apache_http" tag="4.1.1"/> + <include source="maven-public" org="org.apache.httpcomponents" name="httpclient" conf="apache_http" tag="4.3.2"/> </module-selection> </input> Modified: branches/vexi3/org.vexi-library.net/meta/module.xml =================================================================== --- branches/vexi3/org.vexi-library.net/meta/module.xml 2014-01-30 08:06:18 UTC (rev 4646) +++ branches/vexi3/org.vexi-library.net/meta/module.xml 2014-02-04 08:15:12 UTC (rev 4647) @@ -10,7 +10,7 @@ <dependencies> <!-- <checked-in name="httpcore-4.0.1.jar" conf="apache_http" type="java_classes.jar"/> --> - <dependency source="maven-public" conf="apache_http" org="org.apache.httpcomponents" name="httpclient" tag="4.1.1"/> + <dependency source="maven-public" conf="apache_http" org="org.apache.httpcomponents" name="httpclient" tag="4.3.2"/> <dependency source="local" name="library.crypto" branch="trunk"/> <!-- Test Dependencies --> Modified: branches/vexi3/org.vexi-library.net/src/main/jpp/org/ibex/net/ApacheHTTP.jpp =================================================================== --- branches/vexi3/org.vexi-library.net/src/main/jpp/org/ibex/net/ApacheHTTP.jpp 2014-01-30 08:06:18 UTC (rev 4646) +++ branches/vexi3/org.vexi-library.net/src/main/jpp/org/ibex/net/ApacheHTTP.jpp 2014-02-04 08:15:12 UTC (rev 4647) @@ -5,57 +5,70 @@ import java.net.Socket; import org.apache.http.*; +import org.apache.http.client.ClientProtocolException; import org.apache.http.entity.*; import org.apache.http.impl.*; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.SystemDefaultHttpClient; import org.apache.http.message.*; import org.apache.http.params.*; import org.apache.http.protocol.*; import org.ibex.util.*; public class ApacheHTTP implements HTTP { + + static private HttpClientBuilder builder; + static synchronized HttpClientBuilder get(){ + if(builder==null){ + builder = HttpClientBuilder.create(); + builder.useSystemProperties(); + builder.disableCookieManagement(); + builder.disableAuthCaching(); + } + return builder; + } + + static synchronized ApacheHTTP create(Logger logger, String url) throws IOException{ + CloseableHttpClient client = get().build(); + if (url.indexOf("://") == -1) + throw new IOException("URLs must contain a ://"); + + return new ApacheHTTP(client, logger, url); + } + + + final CloseableHttpClient client; final Logger logger; final String url; - boolean ssl; - boolean keepAlive = true; +// boolean keepAlive = true; final String path; - final HttpHost host; + final private HttpHost host; // HttpComponents guff - final HttpParams params; + final private HttpParams params; - final BasicHttpProcessor httpproc; - final HttpRequestExecutor httpexecutor; + final DefaultHttpClientConnection conn; - final ConnectionReuseStrategy connStrategy; - final DefaultHttpClientConnection conn; - static ApacheHTTP stdio = null; - static { - try { - stdio = new ApacheHTTP(DefaultLog.logger, "stdio:"); - } - catch (Exception e) {/*ignore*/} - } - - public ApacheHTTP(Logger logger, String url) throws IOException { + public ApacheHTTP(CloseableHttpClient client, Logger logger, String url) throws IOException { + this.client = client; this.logger = logger; this.url = url; - if (url.startsWith("https:")) { ssl = true; } else if (!url.startsWith("http:")) { throw new IOException("HTTP only supports http/https urls"); } - if (url.indexOf("://") == -1) - throw new IOException("URLs must contain a ://"); + String temphost = url.substring(url.indexOf("://") + 3); path = temphost.substring(temphost.indexOf('/')); temphost = temphost.substring(0, temphost.indexOf('/')); @@ -75,18 +88,6 @@ HttpProtocolParams.setUserAgent(params, "Vexi"); HttpProtocolParams.setUseExpectContinue(params, true); - httpproc = new BasicHttpProcessor(); - // Required protocol interceptors - httpproc.addInterceptor(new RequestContent()); - httpproc.addInterceptor(new RequestTargetHost()); - // Recommended protocol interceptors - httpproc.addInterceptor(new RequestConnControl()); - httpproc.addInterceptor(new RequestUserAgent()); - httpproc.addInterceptor(new RequestExpectContinue()); - - httpexecutor = new HttpRequestExecutor(); - - connStrategy = new DefaultConnectionReuseStrategy(); conn = new DefaultHttpClientConnection(); } @@ -108,7 +109,7 @@ "GET", path); return makeRequest(request); } - + public HTTPResponse POST(String contentType, byte[] content) throws IOException { BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest( "POST", path); @@ -117,7 +118,7 @@ request.setEntity(entity); return makeRequest(request); } - + public HTTPResponse makeRequest(BasicHttpRequest request) throws IOException{ try { if (!conn.isOpen()) { @@ -129,18 +130,14 @@ conn.bind(socket, params); } + HttpContext context = new BasicHttpContext(null); context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn); context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, host); - context.setAttribute(ExecutionContext.HTTP_REQUEST, request); request.setParams(params); - httpexecutor.preProcess(request, httpproc, context); - HttpResponse response = httpexecutor - .execute(request, conn, context); - httpexecutor.postProcess(response, httpproc, context); - if (!connStrategy.keepAlive(response, context)) - keepAlive = false; + + HttpResponse response = client.execute(host, request, context); int statusCode = response.getStatusLine().getStatusCode(); HttpEntity resp = response.getEntity(); @@ -156,7 +153,7 @@ return new HTTPResponse(info, resp.getContent()); } - } catch (HttpException he) { + } catch (ClientProtocolException he) { throw new IOException(he); } } Index: trunk/_ebuild =================================================================== --- trunk/_ebuild 2014-01-30 08:06:18 UTC (rev 4646) +++ trunk/_ebuild 2014-02-04 08:15:12 UTC (rev 4647) Property changes on: trunk/_ebuild ___________________________________________________________________ Modified: svn:ignore ## -17,3 +17,5 ## workspace.xml report + +workspace.conf This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn