Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x
This commit is contained in:
commit
fe1b515d25
|
@ -481,33 +481,38 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
|||
|
||||
case COMPLETE:
|
||||
{
|
||||
if (!_response.isCommitted() && !_request.isHandled())
|
||||
try
|
||||
{
|
||||
_response.sendError(HttpStatus.NOT_FOUND_404);
|
||||
}
|
||||
else
|
||||
{
|
||||
// RFC 7230, section 3.3.
|
||||
int status = _response.getStatus();
|
||||
boolean hasContent = !(_request.isHead() ||
|
||||
if (!_response.isCommitted() && !_request.isHandled())
|
||||
{
|
||||
_response.sendError(HttpStatus.NOT_FOUND_404);
|
||||
}
|
||||
else
|
||||
{
|
||||
// RFC 7230, section 3.3.
|
||||
int status = _response.getStatus();
|
||||
boolean hasContent = !(_request.isHead() ||
|
||||
HttpMethod.CONNECT.is(_request.getMethod()) && status == HttpStatus.OK_200 ||
|
||||
HttpStatus.isInformational(status) ||
|
||||
status == HttpStatus.NO_CONTENT_204 ||
|
||||
status == HttpStatus.NOT_MODIFIED_304);
|
||||
if (hasContent && !_response.isContentComplete(_response.getHttpOutput().getWritten()))
|
||||
{
|
||||
if (isCommitted())
|
||||
abort(new IOException("insufficient content written"));
|
||||
else
|
||||
_response.sendError(HttpStatus.INTERNAL_SERVER_ERROR_500,"insufficient content written");
|
||||
if (hasContent && !_response.isContentComplete(_response.getHttpOutput().getWritten()))
|
||||
{
|
||||
if (isCommitted())
|
||||
abort(new IOException("insufficient content written"));
|
||||
else
|
||||
_response.sendError(HttpStatus.INTERNAL_SERVER_ERROR_500, "insufficient content written");
|
||||
}
|
||||
}
|
||||
_response.closeOutput();
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
_request.setHandled(true);
|
||||
_state.onComplete();
|
||||
onCompleted();
|
||||
}
|
||||
_response.closeOutput();
|
||||
_request.setHandled(true);
|
||||
|
||||
_state.onComplete();
|
||||
|
||||
onCompleted();
|
||||
|
||||
break loop;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.BindException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
|
@ -336,7 +337,14 @@ public class ServerConnector extends AbstractNetworkConnector
|
|||
|
||||
InetSocketAddress bindAddress = getHost() == null ? new InetSocketAddress(getPort()) : new InetSocketAddress(getHost(), getPort());
|
||||
serverChannel.socket().setReuseAddress(getReuseAddress());
|
||||
serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
|
||||
try
|
||||
{
|
||||
serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
|
||||
}
|
||||
catch (BindException e)
|
||||
{
|
||||
throw new IOException("Failed to bind to " + bindAddress, e);
|
||||
}
|
||||
}
|
||||
|
||||
return serverChannel;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
|
@ -26,15 +27,17 @@ import static org.hamcrest.Matchers.is;
|
|||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.BindException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -296,11 +299,28 @@ public class ServerConnectorTest
|
|||
server.stop();
|
||||
|
||||
assertThat(connector.getTransport(),Matchers.nullValue());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindToAddressWhichIsInUse() throws Exception
|
||||
{
|
||||
try (ServerSocket socket = new ServerSocket(0))
|
||||
{
|
||||
final int port = socket.getLocalPort();
|
||||
|
||||
Server server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(port);
|
||||
server.addConnector(connector);
|
||||
|
||||
HandlerList handlers = new HandlerList();
|
||||
handlers.addHandler(new DefaultHandler());
|
||||
|
||||
server.setHandler(handlers);
|
||||
|
||||
IOException x = assertThrows(IOException.class, () -> server.start());
|
||||
assertThat(x.getCause(), instanceOf(BindException.class));
|
||||
assertThat(x.getMessage(), containsString("0.0.0.0:" + port));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class StartArgs
|
|||
{
|
||||
ver = ManifestUtils.getManifest(StartArgs.class)
|
||||
.map(Manifest::getMainAttributes)
|
||||
.filter(attributes -> "Eclipse.org - Jetty".equals(attributes.getValue("Implementation-Vendor")))
|
||||
.filter(attributes -> "Eclipse Jetty Project".equals(attributes.getValue("Implementation-Vendor")))
|
||||
.map(attributes -> attributes.getValue("Implementation-Version"))
|
||||
.orElse(null);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class Jetty
|
|||
|
||||
Package pkg = Jetty.class.getPackage();
|
||||
if (pkg != null &&
|
||||
"Eclipse.org - Jetty".equals(pkg.getImplementationVendor()) &&
|
||||
"Eclipse Jetty Project".equals(pkg.getImplementationVendor()) &&
|
||||
pkg.getImplementationVersion() != null)
|
||||
VERSION = pkg.getImplementationVersion();
|
||||
else
|
||||
|
|
|
@ -1457,9 +1457,22 @@ public class FileSystemResourceTest
|
|||
public void testUtf8Dir(Class resourceClass) throws Exception
|
||||
{
|
||||
Path dir = workDir.getEmptyPathDir();
|
||||
Path utf8Dir = dir.resolve("bãm");
|
||||
Files.createDirectories(utf8Dir);
|
||||
|
||||
Path utf8Dir;
|
||||
|
||||
try
|
||||
{
|
||||
utf8Dir = dir.resolve("bãm");
|
||||
Files.createDirectories(utf8Dir);
|
||||
}
|
||||
catch (InvalidPathException e)
|
||||
{
|
||||
// if unable to create file, no point testing the rest.
|
||||
// this is the path that occurs if you have a system that doesn't support UTF-8
|
||||
// directory names (or you simply don't have a Locale set properly)
|
||||
assumeTrue(true, "Not supported on this OS");
|
||||
return;
|
||||
}
|
||||
|
||||
Path file = utf8Dir.resolve("file.txt");
|
||||
Files.createFile(file);
|
||||
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -303,7 +303,7 @@
|
|||
<Bundle-ManifestVersion>2</Bundle-ManifestVersion>
|
||||
<Bundle-Name>${project.name}</Bundle-Name>
|
||||
<Bundle-SymbolicName>${bundle-symbolic-name}.source</Bundle-SymbolicName>
|
||||
<Bundle-Vendor>Eclipse.org - Jetty</Bundle-Vendor>
|
||||
<Bundle-Vendor>Eclipse Jetty Project</Bundle-Vendor>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Eclipse-SourceBundle>${bundle-symbolic-name};version="${parsedVersion.osgiVersion}";roots:="."</Eclipse-SourceBundle>
|
||||
</manifestEntries>
|
||||
|
@ -485,7 +485,7 @@
|
|||
<manifestEntries>
|
||||
<Automatic-Module-Name>${jpms-module-name}</Automatic-Module-Name>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
<Implementation-Vendor>Eclipse.org - Jetty</Implementation-Vendor>
|
||||
<Implementation-Vendor>Eclipse Jetty Project</Implementation-Vendor>
|
||||
<url>${jetty.url}</url>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
|
|
Loading…
Reference in New Issue