Set the content length and possibly the checksums.
517250
def set_length_and_maybe_checksums(self, record, payload_offset=None):
        ''''''
        if self._params.digests:
            record.compute_checksum(payload_offset)
        else:
            record.set_content_length()
1213339
def record_content_length(self):
        """"""
        untldict = py2dict(self)
        untldict.pop('meta', None)
        return len(str(untldict))
658791
public static long getFileLengthFromBlockSize(long blockSize,
      int bytesPerChecksum, int checksumSize) {
    long numChunks; 
    if (blockSize % bytesPerChecksum == 0) {    
      numChunks = blockSize / bytesPerChecksum; 
    } else {    
      numChunks = blockSize / bytesPerChecksum + 1; 
    }   
    return blockSize + numChunks * checksumSize 
        + BlockInlineChecksumReader.getHeaderSize();  
  }
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)
1197345
private static void setContentLength(HttpRequest req, HttpHeaders headers, int contentLength) {
        // https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4
        // prohibits to send message body for below cases.
        // and in those cases, content should be empty.
        if (req.method() == HttpMethod.HEAD || ArmeriaHttpUtil.isContentAlwaysEmpty(headers.status())) {
            return;
        }
        headers.setInt(HttpHeaderNames.CONTENT_LENGTH, contentLength);
    }
542666
def update_contents(self, stream, seek=0, size=None, chunk_size=None,
                        progress_callback=None, **kwargs):
        
        self.checksum = None
        return self.storage(**kwargs).update(
            stream, seek=seek, size=size, chunk_size=chunk_size,
            progress_callback=progress_callback
        )
59269
protected void setContentSize(final long size) {
        try {
            getDescriptionNode().setProperty(CONTENT_SIZE, size);
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
731266
def __SetTotal(self, info):
        """"""
        if 'content-range' in info:
            _, _, total = info['content-range'].rpartition('/')
            if total != '*':
                self.__total_size = int(total)
        # Note "total_size is None" means we don't know it; if no size
        # info was returned on our initial range request, that means we
        # have a 0-byte file. (That last statement has been verified
        # empirically, but is not clearly documented anywhere.)
        if self.total_size is None:
            self.__total_size = 0
500522
public void setLength(long size) throws IOException, RepositoryException
   {
      if (!changed)
      {
         internalData = createEditableCopy(this.getInternalData());
      }

      ((EditableValueData)internalData).setLength(size);
      invalidateStream();
   }
960188
def fixed_length(cls, l, allow_empty=False):
        """"""
        return cls(l, l, allow_empty=allow_empty)
107308
private void setup() {
        try {
            this.partBoundary = ("--" + boundary).getBytes("UTF-8");
            this.trailingBoundary = ("--" + boundary + "--").getBytes("UTF-8");
            this.contentType = "content-type: application/json".getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }

        attachments = new ArrayList<Attachment>();

        // some preamble
        contentLength += partBoundary.length;
        contentLength += 6; // 3 * crlf
        contentLength += contentType.length;

        // although we haven't added it yet, account for the trailing boundary
        contentLength += 2; // crlf
        contentLength += trailingBoundary.length;
    }
1179466
def set_content_type (self):
        """"""
        if self.url:
            self.content_type = mimeutil.guess_mimetype(self.url, read=self.get_content)
        else:
            self.content_type = u""
256204
@Override
    public void setContentLength(long length) {
        this.message.setContentLength(length);
        if (this.body != null) {
            this.body.setContentLength(length);
        }
    }
278697
def add_size_info (self):
        """"""
        if self.headers and "Content-Length" in self.headers and \
           "Transfer-Encoding" not in self.headers:
            # Note that content-encoding causes size differences since
            # the content data is always decoded.
            try:
                self.size = int(self.getheader("Content-Length"))
            except (ValueError, OverflowError):
                pass
        else:
            self.size = -1
1133715
def safe_size_check(checked_path, error_detail, max_bytes=500000000):
    """"""
    actual_size = 0
    for dirpath, dirnames, filenames in os.walk(checked_path):
        for f in filenames:
            fp = os.path.join(dirpath, f)
            actual_size += os.path.getsize(fp)

    assert actual_size <= max_bytes, "Path {} size of {} >= {} bytes. {}".format(
        checked_path, actual_size, max_bytes, error_detail)
882517
public static String approximateContentHash(long length, long modTime) {
    // approximating the content hash with the file length and modtime.
    StringBuilder sb = new StringBuilder();
    sb.append('(');
    sb.append("len:");
    sb.append(length);
    sb.append(", ");
    sb.append("modtime:");
    sb.append(modTime);
    sb.append(')');
    return sb.toString();
  }
943357
def set_data_length(self, length):
        # type: (int) -> None
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('Directory Record not yet initialized')
        self.data_length = length