Check that the message content is within the configured length limit.
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
443767
private static int contentLength(Object msg) {
        if (msg instanceof MemcacheContent) {
            return ((MemcacheContent) msg).content().readableBytes();
        }
        if (msg instanceof ByteBuf) {
            return ((ByteBuf) msg).readableBytes();
        }
        if (msg instanceof FileRegion) {
            return (int) ((FileRegion) msg).count();
        }
        throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg));
    }
782920
private static void checkPreconditions(final Collection<Integer> requriedLengths) {
        if( requriedLengths == null ) {
            throw new NullPointerException("requriedLengths should not be null");
        } else if( requriedLengths.isEmpty()) {
            throw new IllegalArgumentException("requriedLengths should not be empty");
        }
    }
140634
def length(min=None, max=None):
    

    def validate(value):
        if min and len(value) < min:
            return e("{} does not have a length of at least {}", value, min)
        if max and len(value) > max:
            return e("{} does not have a length of at most {}", value, max)
    return validate
771217
public void hasLength(int expectedLength) {
    checkArgument(expectedLength >= 0, "expectedLength(%s) must be >= 0", expectedLength);
    check("length()").that(actual().length()).isEqualTo(expectedLength);
  }
1307119
private boolean okayToSendMessage(IRTMPEvent message) {
        if (message instanceof IStreamData) {
            final long now = System.currentTimeMillis();
            // check client buffer size
            if (isClientBufferFull(now)) {
                return false;
            }
            // get pending message count
            long pending = pendingMessages();
            if (bufferCheckInterval > 0 && now >= nextCheckBufferUnderrun) {
                if (pending > underrunTrigger) {
                    // client is playing behind speed, notify him
                    sendInsufficientBandwidthStatus(currentItem.get());
                }
                nextCheckBufferUnderrun = now + bufferCheckInterval;
            }
            // check for under run
            if (pending > underrunTrigger) {
                // too many messages already queued on the connection
                return false;
            }
            return true;
        } else {
            String itemName = "Undefined";
            // if current item exists get the name to help debug this issue
            if (currentItem.get() != null) {
                itemName = currentItem.get().getName();
            }
            Object[] errorItems = new Object[] { message.getClass(), message.getDataType(), itemName };
            throw new RuntimeException(String.format("Expected IStreamData but got %s (type %s) for %s", errorItems));
        }
    }
1020079
private void checkAndAddLengths(final int... requiredLengths) {
		for( final int length : requiredLengths ) {
			if( length < 0 ) {
				throw new IllegalArgumentException(String.format("required length cannot be negative but was %d",
					length));
			}
			this.requiredLengths.add(length);
		}
	}
213467
def check_subscriber_key_length(app_configs=None, **kwargs):
	
	from . import settings as djstripe_settings

	messages = []

	key = djstripe_settings.SUBSCRIBER_CUSTOMER_KEY
	key_size = len(str(key))
	if key and key_size > 40:
		messages.append(
			checks.Error(
				"DJSTRIPE_SUBSCRIBER_CUSTOMER_KEY must be no more than 40 characters long",
				hint="Current value: %r (%i characters)" % (key, key_size),
				id="djstripe.E001",
			)
		)

	return messages
1304705
def calculate_content_length(self):
        """"""
        try:
            self._ensure_sequence()
        except RuntimeError:
            return None
        return sum(len(x) for x in self.response)
226360
def maxLength(self):
        """"""
        value = self._schema.get("maxLength", None)
        if value is None:
            return
        if not isinstance(value, int):
            raise SchemaError(
                "maxLength value {0!r} is not an integer".format(value))
        return value
347283
def determineLength(length):
        
        integer = ord(length)

        if integer < 128:
            return 0
        elif integer < 192:
            return 1
        elif integer < 224:
            return 2
        elif integer < 240:
            return 3
        else:
            raise ConnectionError('Unknown controll byte {}'.format(length))
1283262
private boolean validateRange(Range range, long contentLength)
   {
      long start = range.getStart();
      long end = range.getEnd();

      // range set as bytes:-100
      // take 100 bytes from end
      if (start < 0 && end == -1)
      {
         if ((-1 * start) >= contentLength)
         {
            start = 0;
            end = contentLength - 1;
         }
         else
         {
            start = contentLength + start;
            end = contentLength - 1;
         }
      }

      // range set as bytes:100-
      // take from 100 to the end
      if (start >= 0 && end == -1)
         end = contentLength - 1;

      // normal range set as bytes:100-200
      // end can be greater then content-length
      if (end >= contentLength)
         end = contentLength - 1;

      if (start >= 0 && end >= 0 && start <= end)
      {
         range.setStart(start);
         range.setEnd(end);
         return true;
      }
      return false;
   }
105124
def message_length(message):
    '''
    
    '''
    length = 0
    for char in map(east_asian_width, message):
        if char == 'W':
            length += 2
        elif char == 'Na':
            length += 1

    return length
74463
def check_content_size(url, headers, max_content_bytes):
    
    if not max_content_bytes:
        return
    if 'content-length' in headers:
        size = int(headers['content-length'])
        if size > max_content_bytes:
            msg = 'URL content of %s with %d bytes exceeds %d bytes.' % (url, size, max_content_bytes)
            raise IOError(msg)
1009955
public void expectMax(String name, double maxLength, String message) {
        String value = Optional.ofNullable(get(name)).orElse("");

        if (StringUtils.isNumeric(value)) {
            if (Double.parseDouble(value) > maxLength) {
                addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MAX_KEY.name(), name, maxLength)));
            }
        } else {
            if (value.length() > maxLength) {
                addError(name, Optional.ofNullable(message).orElse(messages.get(Validation.MAX_KEY.name(), name, maxLength)));
            }
        }
    }
542858
function matchLength(text, exp) {
  const match = text.match(exp);
  return match ? match[0].length : 0;
}
363386
def _has_message(self):
        
        sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding)
        return sep in self._receive_buffer