Skip to content

Commit

Permalink
Servlet 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
eschultink committed Jul 16, 2024
1 parent d774f06 commit 9d030ef
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 5 deletions.
4 changes: 2 additions & 2 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@
<!-- </dependency>-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ public String getCharacterEncoding() {
public int getContentLength() {
return -1;
}

@Override
public long getContentLengthLong() {
return 0;
}

@Override
public String getContentType() {
return contentType;
Expand All @@ -168,8 +174,25 @@ public ServletInputStream getInputStream() {
}
getInputStreamCalled = true; // so that getReader() can no longer be called


final InputStream in = new ByteArrayInputStream(bodyData);
return new ServletInputStream() {
@Override
public boolean isFinished() {

return true;
}

@Override
public boolean isReady() {
return true;
}

@Override
public void setReadListener(ReadListener readListener) {

}

@Override
public int read() throws IOException {
return in.read();
Expand Down Expand Up @@ -202,6 +225,41 @@ public int getLocalPort() {
return port;
}

@Override
public ServletContext getServletContext() {
return null;
}

@Override
public AsyncContext startAsync() throws IllegalStateException {
return null;
}

@Override
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
return null;
}

@Override
public boolean isAsyncStarted() {
return false;
}

@Override
public boolean isAsyncSupported() {
return false;
}

@Override
public AsyncContext getAsyncContext() {
return null;
}

@Override
public DispatcherType getDispatcherType() {
return null;
}

@Override
public Locale getLocale() {
return Locale.US;
Expand Down Expand Up @@ -437,6 +495,11 @@ public HttpSession getSession() {
throw new UnsupportedOperationException();
}

@Override
public String changeSessionId() {
throw new UnsupportedOperationException();
}


@Override
public HttpSession getSession(boolean create) {
Expand All @@ -460,7 +523,42 @@ public boolean isRequestedSessionIdFromURL() {

@Override
public boolean isRequestedSessionIdFromUrl() {
return false;

throw new UnsupportedOperationException();
}

@Override
public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException {

throw new UnsupportedOperationException();
}

@Override
public void login(String s, String s1) throws ServletException {

throw new UnsupportedOperationException();
}

@Override
public void logout() throws ServletException {

}

@Override
public Collection<Part> getParts() throws IOException, ServletException {

throw new UnsupportedOperationException();
}

@Override
public Part getPart(String s) throws IOException, ServletException {

throw new UnsupportedOperationException();
}

@Override
public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) throws IOException, ServletException {
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import com.google.common.collect.ListMultimap;
import com.google.common.net.HttpHeaders;

import javax.servlet.WriteListener;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
import java.util.List;
import java.util.Locale;

Expand Down Expand Up @@ -196,6 +198,11 @@ public void setContentLength(int length) {
headers.put(HttpHeaders.CONTENT_LENGTH, Integer.toString(length));
}

@Override
public void setContentLengthLong(long l) {

}

@Override
public void setContentType(String type) {
headers.removeAll(HttpHeaders.CONTENT_TYPE);
Expand Down Expand Up @@ -271,7 +278,7 @@ public String encodeUrl(String s) {

@Override
public String encodeRedirectUrl(String s) {
return "";
throw new UnsupportedOperationException();
}

@Override
Expand Down Expand Up @@ -338,7 +345,7 @@ public synchronized void setStatus(int sc) {

@Override
public void setStatus(int i, String s) {

status = i;
}

public synchronized int getStatus() {
Expand All @@ -349,6 +356,17 @@ public String getHeader(String name) {
return Iterables.getFirst(headers.get(checkNotNull(name)), null);
}

@Override
public Collection<String> getHeaders(String s) {

throw new UnsupportedOperationException();
}

@Override
public Collection<String> getHeaderNames() {
return List.of();
}


private void checkCommit() {
if (isCommitted()) {
Expand Down Expand Up @@ -386,5 +404,17 @@ public void write(int b) throws IOException {
long getCount() {
return count;
}

@Override
public boolean isReady() {

throw new UnsupportedOperationException();
}

@Override
public void setWriteListener(WriteListener writeListener) {

throw new UnsupportedOperationException();
}
}
}

0 comments on commit 9d030ef

Please sign in to comment.