8225512: Replace wildcard address with loopback or local host in tests - part 15
Updates httpserver tests to use the loopback instead of the wildcard wherever possible. Reviewed-by: michaelm
This commit is contained in:
parent
83377c41ff
commit
b99e9165f1
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,9 +25,12 @@
|
||||
* @test
|
||||
* @bug 8068795
|
||||
* @summary HttpServer missing tailing space for some response codes
|
||||
* @run main MissingTrailingSpace
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true MissingTrailingSpace
|
||||
* @author lev.priima@oracle.com
|
||||
*/
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
@ -47,7 +50,8 @@ public class MissingTrailingSpace {
|
||||
private static final String someContext = "/context";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(loopback, 0), 0);
|
||||
try {
|
||||
server.setExecutor(Executors.newFixedThreadPool(1));
|
||||
server.createContext(someContext, new HttpHandler() {
|
||||
@ -68,7 +72,7 @@ public class MissingTrailingSpace {
|
||||
System.out.println("Server started at port "
|
||||
+ server.getAddress().getPort());
|
||||
|
||||
runRawSocketHttpClient("localhost", server.getAddress().getPort());
|
||||
runRawSocketHttpClient(loopback, server.getAddress().getPort());
|
||||
} finally {
|
||||
((ExecutorService)server.getExecutor()).shutdown();
|
||||
server.stop(0);
|
||||
@ -76,7 +80,7 @@ public class MissingTrailingSpace {
|
||||
System.out.println("Server finished.");
|
||||
}
|
||||
|
||||
static void runRawSocketHttpClient(String hostname, int port)
|
||||
static void runRawSocketHttpClient(InetAddress address, int port)
|
||||
throws Exception
|
||||
{
|
||||
Socket socket = null;
|
||||
@ -84,7 +88,7 @@ public class MissingTrailingSpace {
|
||||
BufferedReader reader = null;
|
||||
final String CRLF = "\r\n";
|
||||
try {
|
||||
socket = new Socket(hostname, port);
|
||||
socket = new Socket(address, port);
|
||||
writer = new PrintWriter(new OutputStreamWriter(
|
||||
socket.getOutputStream()));
|
||||
System.out.println("Client connected by socket: " + socket);
|
||||
@ -93,7 +97,7 @@ public class MissingTrailingSpace {
|
||||
writer.print("User-Agent: Java/"
|
||||
+ System.getProperty("java.version")
|
||||
+ CRLF);
|
||||
writer.print("Host: " + hostname + CRLF);
|
||||
writer.print("Host: " + address.getHostName() + CRLF);
|
||||
writer.print("Accept: */*" + CRLF);
|
||||
writer.print("Connection: keep-alive" + CRLF);
|
||||
writer.print(CRLF); // Important, else the server will expect that
|
||||
@ -140,4 +144,3 @@ public class MissingTrailingSpace {
|
||||
System.out.println("Client finished." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,8 @@
|
||||
* @bug 7005016
|
||||
* @summary pit jdk7 b121 sqe test jhttp/HttpServer150013 failing
|
||||
* @run main/othervm -Dsun.net.httpserver.clockTick=1000 -Dsun.net.httpserver.idleInterval=3 Test10
|
||||
* @run main/othervm -Dsun.net.httpserver.clockTick=1000 -Dsun.net.httpserver.idleInterval=3
|
||||
* -Djava.net.preferIPv6Addresses Test10
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -42,7 +44,8 @@ public class Test10 extends Test {
|
||||
public static void main (String[] args) throws Exception {
|
||||
System.out.print ("Test10: ");
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
int port = server.getAddress().getPort();
|
||||
HttpContext c2 = server.createContext ("/test", handler);
|
||||
@ -78,7 +81,7 @@ public class Test10 extends Test {
|
||||
public static void doClient (int port) throws Exception {
|
||||
String s = "GET /test/1.html HTTP/1.1\r\n\r\n";
|
||||
|
||||
Socket socket = new Socket ("localhost", port);
|
||||
Socket socket = new Socket (InetAddress.getLoopbackAddress(), port);
|
||||
OutputStream os = socket.getOutputStream();
|
||||
os.write (s.getBytes());
|
||||
socket.setSoTimeout (10 * 1000);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,12 +25,16 @@
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @summary Light weight HTTP server
|
||||
* @library /test/lib
|
||||
* @run main Test11
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test11
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.io.*;
|
||||
import com.sun.net.httpserver.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
public class Test11 {
|
||||
static class Handler implements HttpHandler {
|
||||
@ -51,7 +55,8 @@ public class Test11 {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
System.out.print ("Test 11: ");
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(loopback, 0), 0);
|
||||
ExecutorService s = Executors.newCachedThreadPool();
|
||||
try {
|
||||
HttpContext ctx = server.createContext (
|
||||
@ -59,9 +64,13 @@ public class Test11 {
|
||||
);
|
||||
s = Executors.newCachedThreadPool();
|
||||
server.start ();
|
||||
URL url = new URL ("http://localhost:" + server.getAddress().getPort()+
|
||||
"/Foo/bar/test.html");
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/Foo/bar/test.html")
|
||||
.toURL();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
int r = urlc.getResponseCode();
|
||||
if (r == 200) {
|
||||
throw new RuntimeException ("wrong response received");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,6 +27,7 @@
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.net.SimpleSSLContext
|
||||
* @run main/othervm Test12
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test12
|
||||
* @summary Light weight HTTP server
|
||||
*/
|
||||
|
||||
@ -37,6 +38,7 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/* basic http/s connectivity test
|
||||
* Tests:
|
||||
@ -56,7 +58,8 @@ public class Test12 extends Test {
|
||||
try {
|
||||
String root = System.getProperty ("test.src")+ "/docs";
|
||||
System.out.print ("Test12: ");
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
s1 = HttpServer.create (addr, 0);
|
||||
s2 = HttpsServer.create (addr, 0);
|
||||
HttpHandler h = new FileServerHandler (root);
|
||||
@ -130,8 +133,13 @@ public class Test12 extends Test {
|
||||
|
||||
public void run () {
|
||||
try {
|
||||
URL url = new URL (protocol+"://localhost:"+port+"/test1/"+f);
|
||||
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme(protocol)
|
||||
.loopback()
|
||||
.port(port)
|
||||
.path("/test1/"+f)
|
||||
.toURL();
|
||||
HttpURLConnection urlc = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
|
||||
if (urlc instanceof HttpsURLConnection) {
|
||||
HttpsURLConnection urlcs = (HttpsURLConnection) urlc;
|
||||
urlcs.setHostnameVerifier (new HostnameVerifier () {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,6 +27,7 @@
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.net.SimpleSSLContext
|
||||
* @run main/othervm Test13
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test13
|
||||
* @summary Light weight HTTP server
|
||||
*/
|
||||
|
||||
@ -38,6 +39,7 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/* basic http/s connectivity test
|
||||
* Tests:
|
||||
@ -61,10 +63,12 @@ public class Test13 extends Test {
|
||||
ha.setLevel(Level.ALL);
|
||||
l.setLevel(Level.ALL);
|
||||
l.addHandler(ha);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
|
||||
try {
|
||||
String root = System.getProperty ("test.src")+ "/docs";
|
||||
System.out.print ("Test13: ");
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
s1 = HttpServer.create (addr, 0);
|
||||
s2 = HttpsServer.create (addr, 0);
|
||||
HttpHandler h = new FileServerHandler (root);
|
||||
@ -136,8 +140,13 @@ public class Test13 extends Test {
|
||||
|
||||
public void run () {
|
||||
try {
|
||||
URL url = new URL (protocol+"://localhost:"+port+"/test1/"+f);
|
||||
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme(protocol)
|
||||
.loopback()
|
||||
.port(port)
|
||||
.path("/test1/"+f)
|
||||
.toURL();
|
||||
HttpURLConnection urlc = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
|
||||
if (urlc instanceof HttpsURLConnection) {
|
||||
HttpsURLConnection urlcs = (HttpsURLConnection) urlc;
|
||||
urlcs.setHostnameVerifier (new HostnameVerifier () {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,9 @@
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @summary Light weight HTTP server
|
||||
* @library /test/lib
|
||||
* @run main Test14
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test14
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -36,6 +39,7 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import javax.security.auth.callback.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/**
|
||||
* Test filters
|
||||
@ -77,7 +81,8 @@ public class Test14 extends Test {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
|
||||
@ -94,9 +99,14 @@ public class Test14 extends Test {
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
System.out.print ("Test14: " );
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
InputStream is = urlc.getInputStream();
|
||||
int x = 0;
|
||||
String output="";
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,9 @@
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @summary Light weight HTTP server
|
||||
* @library /test/lib
|
||||
* @run main Test2
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test2
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -36,6 +39,7 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import javax.security.auth.callback.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/**
|
||||
* Test authentication
|
||||
@ -45,7 +49,8 @@ public class Test2 extends Test {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
BasicAuthenticator a = new BasicAuthenticator ("foobar@test.realm") {
|
||||
@ -60,9 +65,15 @@ public class Test2 extends Test {
|
||||
server.start ();
|
||||
java.net.Authenticator.setDefault (new MyAuthenticator());
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
|
||||
System.out.print ("Test2: " );
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
InputStream is = urlc.getInputStream();
|
||||
int c = 0;
|
||||
while (is.read()!= -1) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,8 @@
|
||||
* @bug 6270015
|
||||
* @summary Light weight HTTP server
|
||||
* @run main/othervm -Dsun.net.httpserver.idleInterval=4 Test3
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true
|
||||
* -Dsun.net.httpserver.idleInterval=4 Test3
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -48,7 +50,8 @@ public class Test3 extends Test {
|
||||
public static void main (String[] args) throws Exception {
|
||||
System.out.print ("Test3: ");
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
int port = server.getAddress().getPort();
|
||||
HttpContext c2 = server.createContext ("/test", handler);
|
||||
@ -135,7 +138,7 @@ public class Test3 extends Test {
|
||||
"GET /test/4.html HTTP/1.1\r\nContent-length: 10\r\n"+
|
||||
"\r\n"+body4;
|
||||
|
||||
Socket socket = new Socket ("localhost", port);
|
||||
Socket socket = new Socket (InetAddress.getLoopbackAddress(), port);
|
||||
OutputStream os = socket.getOutputStream();
|
||||
os.write (s.getBytes());
|
||||
InputStream is = socket.getInputStream();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,8 @@
|
||||
* @bug 6270015
|
||||
* @summary Light weight HTTP server
|
||||
* @run main/othervm -Dsun.net.httpserver.idleInterval=4 Test4
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true
|
||||
* -Dsun.net.httpserver.idleInterval=4 Test4
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -46,7 +48,8 @@ public class Test4 extends Test {
|
||||
public static void main (String[] args) throws Exception {
|
||||
System.out.print ("Test4: ");
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
int port = server.getAddress().getPort();
|
||||
HttpContext c2 = server.createContext ("/test", handler);
|
||||
@ -133,7 +136,7 @@ public class Test4 extends Test {
|
||||
"GET /test/4.html HTTP/1.1\r\nContent-length: 10\r\n"+
|
||||
"\r\n"+body4;
|
||||
|
||||
Socket socket = new Socket ("localhost", port);
|
||||
Socket socket = new Socket (InetAddress.getLoopbackAddress(), port);
|
||||
OutputStream os = socket.getOutputStream();
|
||||
os.write (s.getBytes());
|
||||
InputStream is = socket.getInputStream();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,8 @@
|
||||
* @bug 6270015
|
||||
* @summary Light weight HTTP server
|
||||
* @run main/othervm -Dsun.net.httpserver.idleInterval=4 Test5
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true
|
||||
* -Dsun.net.httpserver.idleInterval=4 Test5
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -47,7 +49,8 @@ public class Test5 extends Test {
|
||||
public static void main (String[] args) throws Exception {
|
||||
System.out.print ("Test5: ");
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
int port = server.getAddress().getPort();
|
||||
HttpContext c2 = server.createContext ("/test", handler);
|
||||
@ -132,7 +135,7 @@ public class Test5 extends Test {
|
||||
"GET /test/4.html HTTP/1.1\r\nContent-length: 10\r\n"+
|
||||
"\r\n"+body4;
|
||||
|
||||
Socket socket = new Socket ("localhost", port);
|
||||
Socket socket = new Socket (InetAddress.getLoopbackAddress(), port);
|
||||
OutputStream os = socket.getOutputStream();
|
||||
os.write (s.getBytes());
|
||||
InputStream is = socket.getInputStream();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,9 @@
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @summary Light weight HTTP server
|
||||
* @library /test/lib
|
||||
* @run main Test6
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test6
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -36,6 +39,7 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import javax.security.auth.callback.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/**
|
||||
* Test POST large file via chunked encoding (unusually small chunks)
|
||||
@ -45,16 +49,23 @@ public class Test6 extends Test {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
|
||||
System.out.print ("Test6: " );
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
urlc.setDoOutput (true);
|
||||
urlc.setRequestMethod ("POST");
|
||||
urlc.setChunkedStreamingMode (32); // small chunks
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,7 +24,10 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @library /test/lib
|
||||
* @summary Light weight HTTP server
|
||||
* @run main Test7
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test7
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -36,6 +39,7 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import javax.security.auth.callback.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/**
|
||||
* Test POST large file via chunked encoding (large chunks)
|
||||
@ -45,16 +49,22 @@ public class Test7 extends Test {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
System.out.print ("Test7: " );
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
urlc.setDoOutput (true);
|
||||
urlc.setRequestMethod ("POST");
|
||||
urlc.setChunkedStreamingMode (16 * 1024); // big chunks
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,9 @@
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.net.SimpleSSLContext
|
||||
* @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.net.URIBuilder
|
||||
* @run main/othervm Test7a
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test7a
|
||||
* @summary Light weight HTTP server
|
||||
*/
|
||||
|
||||
@ -37,6 +38,7 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/**
|
||||
* Test POST large file via chunked encoding (large chunks)
|
||||
@ -51,7 +53,8 @@ public class Test7a extends Test {
|
||||
//h.setLevel (Level.ALL);
|
||||
//log.addHandler (h);
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpsServer server = HttpsServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
@ -60,9 +63,15 @@ public class Test7a extends Test {
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("https://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("https")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
|
||||
System.out.print ("Test7a: " );
|
||||
HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection ();
|
||||
HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
urlc.setDoOutput (true);
|
||||
urlc.setRequestMethod ("POST");
|
||||
urlc.setChunkedStreamingMode (16 * 1024); // big chunks
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,7 +24,10 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @library /test/lib
|
||||
* @summary Light weight HTTP server
|
||||
* @run main Test8
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test8
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -36,6 +39,7 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import javax.security.auth.callback.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/**
|
||||
* Test POST large file via fixed len encoding
|
||||
@ -45,16 +49,23 @@ public class Test8 extends Test {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
|
||||
System.out.print ("Test8: " );
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
urlc.setDoOutput (true);
|
||||
urlc.setRequestMethod ("POST");
|
||||
OutputStream os = new BufferedOutputStream (urlc.getOutputStream());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,9 @@
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.net.SimpleSSLContext
|
||||
* @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.net.URIBuilder
|
||||
* @run main/othervm Test8a
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test8a
|
||||
* @summary Light weight HTTP server
|
||||
*/
|
||||
|
||||
@ -37,6 +38,7 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/**
|
||||
* Test POST large file via fixed len encoding
|
||||
@ -54,7 +56,8 @@ public class Test8a extends Test {
|
||||
ExecutorService executor = null;
|
||||
try {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
server = HttpsServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
executor = Executors.newCachedThreadPool();
|
||||
@ -63,9 +66,15 @@ public class Test8a extends Test {
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("https://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("https")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
|
||||
System.out.print ("Test8a: " );
|
||||
HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection ();
|
||||
HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
urlc.setDoOutput (true);
|
||||
urlc.setRequestMethod ("POST");
|
||||
urlc.setHostnameVerifier (new DummyVerifier());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,9 @@
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.net.SimpleSSLContext
|
||||
* @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.net.URIBuilder
|
||||
* @run main/othervm Test9
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test9
|
||||
* @summary Light weight HTTP server
|
||||
*/
|
||||
|
||||
@ -37,6 +38,7 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/* Same as Test1 but requests run in parallel.
|
||||
*/
|
||||
@ -53,7 +55,8 @@ public class Test9 extends Test {
|
||||
try {
|
||||
String root = System.getProperty ("test.src")+ "/docs";
|
||||
System.out.print ("Test9: ");
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
s1 = HttpServer.create (addr, 0);
|
||||
s2 = HttpsServer.create (addr, 0);
|
||||
HttpHandler h = new FileServerHandler (root);
|
||||
@ -137,8 +140,14 @@ public class Test9 extends Test {
|
||||
|
||||
public void run () {
|
||||
try {
|
||||
URL url = new URL (protocol+"://localhost:"+port+"/test1/"+f);
|
||||
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme(protocol)
|
||||
.loopback()
|
||||
.port(port)
|
||||
.path("/test1/" + f)
|
||||
.toURL();
|
||||
|
||||
HttpURLConnection urlc = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
|
||||
if (urlc instanceof HttpsURLConnection) {
|
||||
HttpsURLConnection urlcs = (HttpsURLConnection) urlc;
|
||||
urlcs.setHostnameVerifier (new HostnameVerifier () {
|
||||
@ -185,7 +194,8 @@ public class Test9 extends Test {
|
||||
String orig = root + "/" + f;
|
||||
compare (new File(orig), temp);
|
||||
temp.delete();
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,9 @@
|
||||
* @test
|
||||
* @bug 6270015
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.net.SimpleSSLContext
|
||||
* @build jdk.test.lib.net.SimpleSSLContext jdk.test.lib.net.URIBuilder
|
||||
* @run main/othervm Test9a
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true Test9a
|
||||
* @summary Light weight HTTP server
|
||||
*/
|
||||
|
||||
@ -37,6 +38,7 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.SimpleSSLContext;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
/* Same as Test1 but requests run in parallel.
|
||||
*/
|
||||
@ -53,7 +55,8 @@ public class Test9a extends Test {
|
||||
try {
|
||||
String root = System.getProperty ("test.src")+ "/docs";
|
||||
System.out.print ("Test9a: ");
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
server = HttpsServer.create (addr, 0);
|
||||
HttpHandler h = new FileServerHandler (root);
|
||||
HttpContext c1 = server.createContext ("/test1", h);
|
||||
@ -131,8 +134,14 @@ public class Test9a extends Test {
|
||||
|
||||
public void run () {
|
||||
try {
|
||||
URL url = new URL (protocol+"://localhost:"+port+"/test1/"+f);
|
||||
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme(protocol)
|
||||
.loopback()
|
||||
.port(port)
|
||||
.path("/test1/" + f)
|
||||
.toURL();
|
||||
|
||||
HttpURLConnection urlc = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
|
||||
if (urlc instanceof HttpsURLConnection) {
|
||||
HttpsURLConnection urlcs = (HttpsURLConnection) urlc;
|
||||
urlcs.setHostnameVerifier (new HostnameVerifier () {
|
||||
@ -179,7 +188,7 @@ public class Test9a extends Test {
|
||||
String orig = root + "/" + f;
|
||||
compare (new File(orig), temp);
|
||||
temp.delete();
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
error = true;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@
|
||||
* @bug 6422914
|
||||
* @library /test/lib
|
||||
* @summary change httpserver exception printouts
|
||||
* @run main TestLogging
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true TestLogging
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -49,7 +51,8 @@ public class TestLogging extends Test {
|
||||
try {
|
||||
System.out.print ("Test9: ");
|
||||
String root = System.getProperty ("test.src")+ "/docs";
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
Logger logger = Logger.getLogger ("com.sun.net.httpserver");
|
||||
logger.setLevel (Level.ALL);
|
||||
Handler h1 = new ConsoleHandler ();
|
||||
@ -70,9 +73,9 @@ public class TestLogging extends Test {
|
||||
.loopback()
|
||||
.port(p1)
|
||||
.path("/test1/smallfile.txt")
|
||||
.toURLUnchecked();
|
||||
.toURL();
|
||||
System.out.println("URL: " + url);
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
InputStream is = urlc.getInputStream();
|
||||
while (is.read() != -1) ;
|
||||
is.close();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,9 @@
|
||||
* @test
|
||||
* @bug 6339483
|
||||
* @summary NullPointerException when creating a HttpContext with no handler
|
||||
* @library /test/lib
|
||||
* @run main B6339483
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true B6339483
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -36,19 +39,26 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import java.security.cert.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
public class B6339483 {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress (loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test");
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
try {
|
||||
InputStream is = urlc.getInputStream();
|
||||
int c = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,6 +24,9 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6341616
|
||||
* @library /test/lib
|
||||
* @run main B6341616
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true B6341616
|
||||
* @summary Server doesnt send response if there is a RuntimeException in validate of BasicAuthFilter
|
||||
*/
|
||||
|
||||
@ -36,12 +39,14 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import java.security.cert.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
public class B6341616 {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress (loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
BasicAuthenticator filter = new BasicAuthenticator ("foobar@test.realm") {
|
||||
@ -56,8 +61,13 @@ public class B6341616 {
|
||||
server.start ();
|
||||
java.net.Authenticator.setDefault (new MyAuthenticator());
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
try {
|
||||
InputStream is = urlc.getInputStream();
|
||||
int c = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
* @test
|
||||
* @bug 6393710
|
||||
* @summary Non authenticated call followed by authenticated call never returns
|
||||
* @run main B6393710
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true B6393710
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -65,7 +67,8 @@ public class B6393710 {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress (loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
ctx.setAuthenticator (new BasicAuthenticator ("test") {
|
||||
@ -76,7 +79,7 @@ public class B6393710 {
|
||||
|
||||
server.start ();
|
||||
|
||||
Socket s = new Socket ("localhost", server.getAddress().getPort());
|
||||
Socket s = new Socket (loopback, server.getAddress().getPort());
|
||||
s.setSoTimeout (5000);
|
||||
|
||||
OutputStream os = s.getOutputStream();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,6 +24,9 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6526158
|
||||
* @library /test/lib
|
||||
* @run main B6526158
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true B6526158
|
||||
* @summary HttpExchange.getRequestBody().close() throws Exception
|
||||
*/
|
||||
|
||||
@ -36,6 +39,7 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import java.security.cert.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
public class B6526158 {
|
||||
|
||||
@ -44,7 +48,8 @@ public class B6526158 {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress (loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
|
||||
@ -52,8 +57,13 @@ public class B6526158 {
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
urlc.setDoOutput (true);
|
||||
try {
|
||||
OutputStream os = new BufferedOutputStream (urlc.getOutputStream());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,7 +24,10 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6526913
|
||||
* @library /test/lib
|
||||
* @run main/othervm -Dhttp.keepAlive=false B6526913
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true
|
||||
* -Dhttp.keepAlive=false B6526913
|
||||
* @summary HttpExchange.getResponseBody().close() throws Exception
|
||||
*/
|
||||
|
||||
@ -37,12 +40,14 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import java.security.cert.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
public class B6526913 {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress (loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
|
||||
@ -50,8 +55,13 @@ public class B6526913 {
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection (Proxy.NO_PROXY);
|
||||
try {
|
||||
InputStream is = urlc.getInputStream();
|
||||
int c ,count = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@
|
||||
* @test
|
||||
* @bug 6529200
|
||||
* @run main/othervm B6529200
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true B6529200
|
||||
* @summary lightweight http server does not work with http1.0 clients
|
||||
*/
|
||||
|
||||
@ -42,7 +43,8 @@ public class B6529200 {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress (loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
|
||||
@ -52,7 +54,7 @@ public class B6529200 {
|
||||
|
||||
/* test 1: keep-alive */
|
||||
|
||||
Socket sock = new Socket ("localhost", server.getAddress().getPort());
|
||||
Socket sock = new Socket (loopback, server.getAddress().getPort());
|
||||
OutputStream os = sock.getOutputStream();
|
||||
System.out.println ("GET /test/foo HTTP/1.0\r\nConnection: keep-alive\r\n\r\n");
|
||||
os.write ("GET /test/foo HTTP/1.0\r\nConnection: keep-alive\r\n\r\n".getBytes());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,9 @@
|
||||
* @test
|
||||
* @bug 6744329
|
||||
* @summary Exception in light weight Http server
|
||||
* @library /test/lib
|
||||
* @run main B6744329
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true B6744329
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -36,20 +39,27 @@ import java.net.*;
|
||||
import java.security.*;
|
||||
import java.security.cert.*;
|
||||
import javax.net.ssl.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
public class B6744329 {
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress (loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
try {
|
||||
InputStream is = urlc.getInputStream();
|
||||
int c = 0;
|
||||
@ -59,6 +69,7 @@ public class B6744329 {
|
||||
System.out.println ("OK");
|
||||
} catch (IOException e) {
|
||||
System.out.println ("exception");
|
||||
e.printStackTrace();
|
||||
error = true;
|
||||
}
|
||||
server.stop(2);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,7 +24,10 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6886436
|
||||
* @summary
|
||||
* @summary HttpServer should not send a body with 204 response.
|
||||
* @library /test/lib
|
||||
* @run main B6886436
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true B6886436
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
@ -34,6 +37,7 @@ import java.util.concurrent.*;
|
||||
import java.util.logging.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
public class B6886436 {
|
||||
|
||||
@ -44,20 +48,26 @@ public class B6886436 {
|
||||
logger.addHandler (c);
|
||||
logger.setLevel (Level.WARNING);
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress (loopback, 0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
HttpContext ctx = server.createContext ("/test", handler);
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
server.setExecutor (executor);
|
||||
server.start ();
|
||||
|
||||
URL url = new URL ("http://localhost:"+server.getAddress().getPort()+"/test/foo.html");
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/test/foo.html")
|
||||
.toURL();
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
try {
|
||||
InputStream is = urlc.getInputStream();
|
||||
while (is.read()!= -1) ;
|
||||
is.close ();
|
||||
urlc = (HttpURLConnection)url.openConnection ();
|
||||
urlc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
urlc.setReadTimeout (3000);
|
||||
is = urlc.getInputStream();
|
||||
while (is.read()!= -1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,20 +25,26 @@
|
||||
* @test
|
||||
* @bug 6756771 6755625
|
||||
* @summary com.sun.net.httpserver.HttpServer should handle POSTs larger than 2Gig
|
||||
* @library /test/lib
|
||||
* @run main FixedLengthInputStream
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true FixedLengthInputStream
|
||||
*/
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.Socket;
|
||||
import java.util.logging.*;
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
public class FixedLengthInputStream
|
||||
{
|
||||
@ -48,8 +54,13 @@ public class FixedLengthInputStream
|
||||
HttpServer httpServer = startHttpServer();
|
||||
int port = httpServer.getAddress().getPort();
|
||||
try {
|
||||
URL url = new URL("http://localhost:" + port + "/flis/");
|
||||
HttpURLConnection uc = (HttpURLConnection)url.openConnection();
|
||||
URL url = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(port)
|
||||
.path("/flis/")
|
||||
.toURLUnchecked();
|
||||
HttpURLConnection uc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY);
|
||||
uc.setDoOutput(true);
|
||||
uc.setRequestMethod("POST");
|
||||
uc.setFixedLengthStreamingMode(POST_SIZE);
|
||||
@ -90,7 +101,8 @@ public class FixedLengthInputStream
|
||||
logger.setLevel(Level.FINEST);
|
||||
logger.addHandler(outHandler);
|
||||
}
|
||||
HttpServer httpServer = HttpServer.create(new InetSocketAddress(0), 0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
HttpServer httpServer = HttpServer.create(new InetSocketAddress(loopback, 0), 0);
|
||||
httpServer.createContext("/flis/", new MyHandler(POST_SIZE));
|
||||
httpServer.start();
|
||||
return httpServer;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -24,11 +24,16 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6886723
|
||||
* @library /test/lib
|
||||
* @run main HeadTest
|
||||
* @run main/othervm -Djava.net.preferIPv6Addresses=true HeadTest
|
||||
* @summary light weight http server doesn't return correct status code for HEAD requests
|
||||
*/
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -37,6 +42,7 @@ import com.sun.net.httpserver.HttpContext;
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import jdk.test.lib.net.URIBuilder;
|
||||
|
||||
public class HeadTest {
|
||||
|
||||
@ -45,7 +51,8 @@ public class HeadTest {
|
||||
}
|
||||
|
||||
static void server() throws Exception {
|
||||
InetSocketAddress inetAddress = new InetSocketAddress(0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress inetAddress = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create(inetAddress, 5);
|
||||
try {
|
||||
server.setExecutor(Executors.newFixedThreadPool(5));
|
||||
@ -88,7 +95,13 @@ public class HeadTest {
|
||||
}
|
||||
});
|
||||
server.start();
|
||||
String urlStr = "http://localhost:" + server.getAddress().getPort() + "/";
|
||||
String urlStr = URIBuilder.newBuilder()
|
||||
.scheme("http")
|
||||
.loopback()
|
||||
.port(server.getAddress().getPort())
|
||||
.path("/")
|
||||
.build()
|
||||
.toString();
|
||||
System.out.println("Server is at " + urlStr);
|
||||
|
||||
// Run the chunked client
|
||||
@ -107,7 +120,7 @@ public class HeadTest {
|
||||
}
|
||||
|
||||
static void runClient(String urlStr) throws Exception {
|
||||
HttpURLConnection conn = (HttpURLConnection) new URL(urlStr).openConnection();
|
||||
HttpURLConnection conn = (HttpURLConnection) new URL(urlStr).openConnection(Proxy.NO_PROXY);
|
||||
conn.setRequestMethod("HEAD");
|
||||
int status = conn.getResponseCode();
|
||||
if (status != 200) {
|
||||
|
@ -90,7 +90,8 @@ public class TruncatedRequestBody {
|
||||
logger.setLevel(Level.ALL);
|
||||
logger.addHandler(h);
|
||||
|
||||
InetSocketAddress addr = new InetSocketAddress(0);
|
||||
InetAddress loopback = InetAddress.getLoopbackAddress();
|
||||
InetSocketAddress addr = new InetSocketAddress(loopback, 0);
|
||||
HttpServer server = HttpServer.create(addr, 10);
|
||||
HttpContext ct = server.createContext("/", new Handler());
|
||||
ExecutorService ex = Executors.newCachedThreadPool();
|
||||
@ -101,7 +102,7 @@ public class TruncatedRequestBody {
|
||||
|
||||
// Test 1: fixed length
|
||||
|
||||
Socket sock = new Socket(InetAddress.getLoopbackAddress(), port);
|
||||
Socket sock = new Socket(loopback, port);
|
||||
String s1 = "POST /foo HTTP/1.1\r\nContent-length: 200000\r\n"
|
||||
+ "\r\nfoo bar99";
|
||||
|
||||
@ -115,7 +116,7 @@ public class TruncatedRequestBody {
|
||||
|
||||
String s2 = "POST /foo HTTP/1.1\r\nTransfer-encoding: chunked\r\n\r\n" +
|
||||
"100\r\nFoo bar";
|
||||
sock = new Socket(InetAddress.getLoopbackAddress(), port);
|
||||
sock = new Socket(loopback, port);
|
||||
os = sock.getOutputStream();
|
||||
os.write(s2.getBytes(StandardCharsets.ISO_8859_1));
|
||||
Thread.sleep(500);
|
||||
|
Loading…
x
Reference in New Issue
Block a user