Retrieves and validates the content length from the REST request.

@return true if has content length
543208
protected boolean hasContentLength() {
        boolean result = false;
        String contentLength = this.request.getHeader(RestMessageHeaders.CONTENT_LENGTH);
        if(contentLength != null) {
            try {
                Long.parseLong(contentLength);
                result = true;
            } catch(NumberFormatException nfe) {
                logger.error("Exception when validating put request. Incorrect content length parameter. Cannot parse this to long: "
                                     + contentLength + ". Details: " + nfe.getMessage(),
                             nfe);
                RestErrorHandler.writeErrorResponse(this.messageEvent,
                                                    HttpResponseStatus.BAD_REQUEST,
                                                    "Incorrect content length parameter. Cannot parse this to long: "
                                                            + contentLength + ". Details: "
                                                            + nfe.getMessage());
            }
        } else {
            logger.error("Error when validating put request. Missing Content-Length header.");
            RestErrorHandler.writeErrorResponse(this.messageEvent,
                                                HttpResponseStatus.BAD_REQUEST,
                                                "Missing Content-Length header");
        }

        return result;
    }
352593
def is_within_content_length_limit(payload, api_config):
        
        length_limit = api_config.get('content_length_limit')
        if (length_limit is not None) and (payload["content"] is not None):
            content_length = len(payload["content"])
            if content_length > length_limit:
                return "Payload content too long: %s > %s" % (
                    content_length, length_limit)
        return None
1300323
public static Validation<String> length(int minSize, int maxSize) {
        return moreThan(minSize).and(lessThan(maxSize));
    }
1156517
def request_length(self):
        
        remainder = self.stop_at - self.offset
        return self.chunk_size if remainder > self.chunk_size else remainder
1324038
protected boolean isWeb() {
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		if (attributes == null) {
			return false;
		}
		HttpServletRequest request = attributes.getRequest();
		if (request == null) {
			return false;
		}
		return true;
	}
322341
@InterfaceAudience.Public
    public long getLength() {
        Number length = (Number) metadata.get("length");
        if (length != null) {
            return length.longValue();
        } else {
            return 0;
        }
    }
1304705
def calculate_content_length(self):
        """"""
        try:
            self._ensure_sequence()
        except RuntimeError:
            return None
        return sum(len(x) for x in self.response)
259718
@SuppressWarnings("resource")
    public String getLength() {

        try {
            return CmsFileUtil.formatFilesize(
                IOUtils.toByteArray(new FileInputStream(m_variationPath)).length,
                A_CmsUI.get().getLocale());
        } catch (IOException e) {
            return "";
        }
    }
1251729
public long getInstanceLength() {
        // See Content-Range in
        // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
        String contentRange = (String)metadata.get(Headers.CONTENT_RANGE);
        if (contentRange != null) {
            int pos = contentRange.lastIndexOf("/");
            if (pos >= 0)
                return Long.parseLong(contentRange.substring(pos+1));
        }
        return getContentLength();
    }
468892
@Override
    public long getLength() throws IOException
    {
        if (_streamLength != -1) {
            return _streamLength;
        }

        isValidIndex(Integer.MAX_VALUE, 1);
        assert(_isStreamFinished);
        return _streamLength;
    }
378945
@Override
    public boolean hasNext(int startPosition, int contentLength) {
        //("-------------: " + startPosition + ", " + contentLength + ", " + this.position);
        if (startPosition >= 0 && contentLength >= 0) {
            return (this.position) < (startPosition + contentLength);
        }
        return (this.position + 1) < this.content.length;
    }
1364412
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

		ActionErrors errors = null;
		// has the maximum length been exceeded?
		Boolean maxLengthExceeded = (Boolean) request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
		if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {
			errors = new ActionErrors();
			errors.add(ERROR_PROPERTY_MAX_LENGTH_EXCEEDED, new ActionMessage("maxLengthExceeded"));
		} else if (fileMap.size() > MAX_IMAGES_COUNT) {
			errors = new ActionErrors();
			errors.add(ERROR_PROPERTY_MAX_LENGTH_EXCEEDED, new ActionMessage("maxLengthExceeded"));
		} else {
			// retrieve the file name
			Iterator iter = fileMap.values().iterator();
			while (iter.hasNext()) {
				FormFile file = (FormFile) iter.next();
				String fileName = file.getFileName();
				if ((!fileName.toLowerCase().endsWith(".gif")) && !(fileName.toLowerCase().endsWith(".jpg"))
						&& !(fileName.toLowerCase().endsWith(".png"))) {
					errors = new ActionErrors();
					errors.add("notImage", new ActionMessage("notImage"));
				}
			}
		}
		return errors;
	}
1071225
@Pure
	public double getLength() {
		double length = this.roadSegments.getLength();
		if (isValidPrimitive()) {
			BusItineraryHalt halt = this.validHalts.get(0);
			assert halt != null;
			RoadSegment sgmt = halt.getRoadSegment();
			assert sgmt != null;
			Direction1D dir = this.roadSegments.getRoadSegmentDirectionAt(halt.getRoadSegmentIndex());
			assert dir != null;
			if (dir == Direction1D.SEGMENT_DIRECTION) {
				length -= halt.getPositionOnSegment();
			} else {
				length -= sgmt.getLength() - halt.getPositionOnSegment();
			}

			halt = this.validHalts.get(this.validHalts.size() - 1);
			assert halt != null;
			sgmt = halt.getRoadSegment();
			assert sgmt != null;
			dir = this.roadSegments.getRoadSegmentDirectionAt(halt.getRoadSegmentIndex());
			assert dir != null;
			if (dir == Direction1D.SEGMENT_DIRECTION) {
				length -= sgmt.getLength() - halt.getPositionOnSegment();
			} else {
				length -= halt.getPositionOnSegment();
			}

			if (length < 0.) {
				length = 0.;
			}
		}
		return length;
	}
646776
@Override
    public boolean hasContentsOfAllSources() {
        if (sourcesContent == null) {
            return false;
        }
        return this.sourcesContent.size() >= this._sources.size() && !this.sourcesContent.stream().anyMatch(sc -> sc == null);
    }
1201465
public boolean hasNext() {
        // check if we already fetched next item
        if (next != null) {
            return true;
        }

        // check if result set already finished
        if (resultSetFinished) {
            return false;
        }

        // now fetch next item
        next = safeReadNext();

        // check if we got something
        if (next != null) {
            return true;
        }

        // no more items
        resultSetFinished = true;

        return false;
    }
920890
private boolean responseIsInValid() {
        if (response == null) {
            return true;
        }
        else if (!response.isHeadless() && validityCheck) {
            return request.getTransactionID() != response.getTransactionID();
        }
        else {
            return false;
        }
    }
1044342
public int getContentLength() {
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        // 321485
        // PK57679 Start
        int contentLength;
        if (!_setInputDataStreamCalled) // 516233
            contentLength = this._request.getContentLength();
        else
            contentLength = (int)_setInputStreamContentLength;
        // PK57679 End
        if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
            logger.logp(Level.FINE, CLASS_NAME,"getContentLength", "this->"+this+": "+" length --> " + String.valueOf(contentLength));
        }
        return contentLength;
    }