nice unit test
now hack AbstractHttpClientWagon.setHeaders to add a User-Agent
header:
method.addHeader( "User-Agent", "test" );
and it works:
- >> "GET /maven2/junit/junit/maven-metadata.xml HTTP/1.1[\r][\n]"
- >> "Cache-control: no-cache[\r][\n]"
- >> "Cache-store: no-store[\r][\n]"
- >> "Pragma: no-cache[\r][\n]"
- >> "Expires: 0[\r][\n]"
- >> "Accept-Encoding: gzip[\r][\n]"
- >> "User-Agent: test[\r][\n]"
- >> "Host: repo.maven.apache.org[\r][\n]"
- >> "Connection: Keep-Alive[\r][\n]"
- >> "[\r][\n]"
- << "HTTP/1.1 200 OK[\r][\n]"
- << "Server: nginx/1.2.1[\r][\n]"
- << "Content-Type: text/xml[\r][\n]"
- << "Last-Modified: Wed, 14 Nov 2012 19:24:17 GMT[\r][\n]"
- << "Via: 1.1 varnish[\r][\n]"
- << "Content-Length: 884[\r][\n]"
- << "Accept-Ranges: bytes[\r][\n]"
- << "Date: Sat, 31 Aug 2013 15:04:10 GMT[\r][\n]"
- << "Via: 1.1 varnish[\r][\n]"
- << "Age: 414111[\r][\n]"
- << "Connection: keep-alive[\r][\n]"
- << "X-Served-By: cache-c48-CHI, cache-am71-AMS[\r][\n]"
- << "X-Cache: HIT, HIT[\r][\n]"
- << "X-Cache-Hits: 1374, 1007[\r][\n]"
- << "[\r][\n]"
seems like central repo now requires User-Agent setting
Regards,
Hervé
Le samedi 31 août 2013 16:24:05 Robert Scholte a écrit :
> I'm not sure if this testcase does exactly the same thing, but the
results
> are the same: failure due to an Access Denied error.
>
>
> ---
> package org.apache.maven.wagon.providers.http;
>
> import org.apache.maven.wagon.InputData;
> import org.apache.maven.wagon.repository.Repository;
> import org.apache.maven.wagon.resource.Resource;
> import org.junit.Test;
>
> public class AbstractHttpClientWagonTest
> {
>
> @Test
> public void test()
>
> throws Exception
>
> {
>
> AbstractHttpClientWagon wagon = new
AbstractHttpClientWagon()
> {
> };
>
> Repository repository = new Repository( "central",
>
> "http://repo.maven.apache.org/maven2" );
>
> wagon.connect( repository );
>
> Resource resource = new Resource();
>
> resource.setName( "junit/junit/maven-metadata.xml" );
>
> InputData inputData = new InputData();
>
> inputData.setResource( resource );
>
> wagon.fillInputData( inputData );
>
> }
>
> }
>
> 2013-08-31 16:18:16,723 [main] DEBUG org.apache.http.headers - >>
GET
> /maven2/junit/junit/maven-metadata.xml HTTP/1.1
> 2013-08-31 16:18:16,726 [main] DEBUG org.apache.http.headers - >>
> Cache-control: no-cache
> 2013-08-31 16:18:16,726 [main] DEBUG org.apache.http.headers - >>
> Cache-store: no-store
> 2013-08-31 16:18:16,726 [main] DEBUG org.apache.http.headers - >>
Pragma:
> no-cache
> 2013-08-31 16:18:16,726 [main] DEBUG org.apache.http.headers - >>
> Expires: 0
> 2013-08-31 16:18:16,726 [main] DEBUG org.apache.http.headers - >>
> Accept-Encoding: gzip
> 2013-08-31 16:18:16,726 [main] DEBUG org.apache.http.headers - >>
Host:
> repo.maven.apache.org
> 2013-08-31 16:18:16,726 [main] DEBUG org.apache.http.headers - >>
> Connection: Keep-Alive
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
> HTTP/1.1 403 Denied Access
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
Server:
> Varnish
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
> Retry-After: 0
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
> Content-Type: text/html; charset=utf-8
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
> Content-Length: 401
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
> Accept-Ranges: bytes
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
Date:
> Sat, 31 Aug 2013 14:18:19 GMT
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
Via:
> 1.1 varnish
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
Age: 0
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
> Connection: close
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<
> X-Served-By: cache-am71-AMS
> 2013-08-31 16:18:16,747 [main] DEBUG org.apache.http.headers - <<