Java Code Examples for javax.servlet.http.HttpServletRequest#getContentLengthLong()
The following examples show how to use
javax.servlet.http.HttpServletRequest#getContentLengthLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogOp.java From rdf-delta with Apache License 2.0 | 5 votes |
private static RDFPatch readPatch(DeltaAction action) throws IOException { HttpServletRequest request = action.request; long byteLength = request.getContentLengthLong(); try ( CountingInputStream in = new CountingInputStream(request.getInputStream()); ) { RDFPatch patch = RDFPatchOps.read(in); if ( byteLength != -1L ) { if ( in.getByteCount() != byteLength ) FmtLog.warn(LOG, "[%d] Length mismatch: Read: %d : Content-Length: %d", action.id, in.getByteCount(), byteLength); } return patch; } }
Example 2
Source File: TracingFilter.java From nakadi with MIT License | 5 votes |
private AsyncRequestListener(final HttpServletRequest request, final HttpServletResponse response, final String flowId, final Span span) { this.response = response; this.flowId = flowId; this.currentSpan = span; this.contentLength = request.getContentLengthLong() == -1 ? 0 : request.getContentLengthLong(); }
Example 3
Source File: LoggingFilter.java From nakadi with MIT License | 5 votes |
private RequestLogInfo(final HttpServletRequest request, final long requestTime) { this.userAgent = Optional.ofNullable(request.getHeader("User-Agent")).orElse("-"); this.user = authorizationService.getSubject().map(Subject::getName).orElse("-"); this.method = request.getMethod(); this.path = request.getRequestURI(); this.query = Optional.ofNullable(request.getQueryString()).map(q -> "?" + q).orElse(""); this.contentEncoding = Optional.ofNullable(request.getHeader(HttpHeaders.CONTENT_ENCODING)).orElse("-"); this.acceptEncoding = Optional.ofNullable(request.getHeader(HttpHeaders.ACCEPT_ENCODING)).orElse("-"); this.contentLength = request.getContentLengthLong() == -1 ? 0 : request.getContentLengthLong(); this.requestTime = requestTime; }
Example 4
Source File: WebdavServlet.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * MKCOL Method. * @param req The Servlet request * @param resp The Servlet response * @throws ServletException If an error occurs * @throws IOException If an IO error occurs */ protected void doMkcol(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String path = getRelativePath(req); WebResource resource = resources.getResource(path); // Can't create a collection if a resource already exists at the given // path if (resource.exists()) { sendNotAllowed(req, resp); return; } if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } if (req.getContentLengthLong() > 0) { DocumentBuilder documentBuilder = getDocumentBuilder(); try { // Document document = documentBuilder.parse(new InputSource(req.getInputStream())); // TODO : Process this request body resp.sendError(WebdavStatus.SC_NOT_IMPLEMENTED); return; } catch(SAXException saxe) { // Parse error - assume invalid content resp.sendError(WebdavStatus.SC_UNSUPPORTED_MEDIA_TYPE); return; } } if (resources.mkdir(path)) { resp.setStatus(WebdavStatus.SC_CREATED); // Removing any lock-null resource which would be present lockNullResources.remove(path); } else { resp.sendError(WebdavStatus.SC_CONFLICT, WebdavStatus.getStatusText (WebdavStatus.SC_CONFLICT)); } }
Example 5
Source File: ServletUtils.java From enkan with Eclipse Public License 1.0 | 4 votes |
private static Long getContentLength(HttpServletRequest servletRequest) { long length = servletRequest.getContentLengthLong(); return length >= 0 ? length : null; }