Home / Function/ addBodyHttpData() — netty Function Reference

addBodyHttpData() — netty Function Reference

Architecture documentation for the addBodyHttpData() function in HttpPostRequestEncoder.java from the netty codebase.

Function java ProtocolCodecs HTTP calls 3 called by 3

Entity Profile

Dependency Diagram

graph TD
  ca6541f6_10eb_06dc_c20a_7a3aee11d69a["addBodyHttpData()"]
  1f646438_907e_54fe_bc9e_a9535d782cc8["HttpPostRequestEncoder"]
  ca6541f6_10eb_06dc_c20a_7a3aee11d69a -->|defined in| 1f646438_907e_54fe_bc9e_a9535d782cc8
  825155a3_ea32_cba2_570b_d7d81a99be81["setBodyHttpDatas()"]
  825155a3_ea32_cba2_570b_d7d81a99be81 -->|calls| ca6541f6_10eb_06dc_c20a_7a3aee11d69a
  4e38b4d7_dd27_b7ac_b26d_b3f5cb2dd3bb["addBodyAttribute()"]
  4e38b4d7_dd27_b7ac_b26d_b3f5cb2dd3bb -->|calls| ca6541f6_10eb_06dc_c20a_7a3aee11d69a
  d1902978_08b3_e45f_2ca3_35c26719bf40["addBodyFileUpload()"]
  d1902978_08b3_e45f_2ca3_35c26719bf40 -->|calls| ca6541f6_10eb_06dc_c20a_7a3aee11d69a
  156929ac_dd34_b8ae_7579_14a87e4c6842["ErrorDataEncoderException()"]
  ca6541f6_10eb_06dc_c20a_7a3aee11d69a -->|calls| 156929ac_dd34_b8ae_7579_14a87e4c6842
  79489c6b_1eaf_03ee_5c22_3f2d84d30bc3["length()"]
  ca6541f6_10eb_06dc_c20a_7a3aee11d69a -->|calls| 79489c6b_1eaf_03ee_5c22_3f2d84d30bc3
  0924a77c_a48d_a433_faa9_50e64aacac26["initMixedMultipart()"]
  ca6541f6_10eb_06dc_c20a_7a3aee11d69a -->|calls| 0924a77c_a48d_a433_faa9_50e64aacac26
  style ca6541f6_10eb_06dc_c20a_7a3aee11d69a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java lines 439–712

    public void addBodyHttpData(InterfaceHttpData data) throws ErrorDataEncoderException {
        if (headerFinalized) {
            throw new ErrorDataEncoderException("Cannot add value once finalized");
        }
        bodyListDatas.add(checkNotNull(data, "data"));
        if (!isMultipart) {
            if (data instanceof Attribute) {
                Attribute attribute = (Attribute) data;
                try {
                    // name=value& with encoded name and attribute
                    String key = encodeAttribute(attribute.getName(), charset);
                    String value = encodeAttribute(attribute.getValue(), charset);
                    Attribute newattribute = factory.createAttribute(request, key, value);
                    multipartHttpDatas.add(newattribute);
                    globalBodySize += newattribute.getName().length() + 1 + newattribute.length() + 1;
                } catch (IOException e) {
                    throw new ErrorDataEncoderException(e);
                }
            } else if (data instanceof FileUpload) {
                // since not Multipart, only name=filename => Attribute
                FileUpload fileUpload = (FileUpload) data;
                // name=filename& with encoded name and filename
                String key = encodeAttribute(fileUpload.getName(), charset);
                String value = encodeAttribute(fileUpload.getFilename(), charset);
                Attribute newattribute = factory.createAttribute(request, key, value);
                multipartHttpDatas.add(newattribute);
                globalBodySize += newattribute.getName().length() + 1 + newattribute.length() + 1;
            }
            return;
        }
        /*
         * Logic:
         * if not Attribute:
         *      add Data to body list
         *      if (duringMixedMode)
         *          add endmixedmultipart delimiter
         *          currentFileUpload = null
         *          duringMixedMode = false;
         *      add multipart delimiter, multipart body header and Data to multipart list
         *      reset currentFileUpload, duringMixedMode
         * if FileUpload: take care of multiple file for one field => mixed mode
         *      if (duringMixedMode)
         *          if (currentFileUpload.name == data.name)
         *              add mixedmultipart delimiter, mixedmultipart body header and Data to multipart list
         *          else
         *              add endmixedmultipart delimiter, multipart body header and Data to multipart list
         *              currentFileUpload = data
         *              duringMixedMode = false;
         *      else
         *          if (currentFileUpload.name == data.name)
         *              change multipart body header of previous file into multipart list to
         *                      mixedmultipart start, mixedmultipart body header
         *              add mixedmultipart delimiter, mixedmultipart body header and Data to multipart list
         *              duringMixedMode = true
         *          else
         *              add multipart delimiter, multipart body header and Data to multipart list
         *              currentFileUpload = data
         *              duringMixedMode = false;
         * Do not add last delimiter! Could be:
         * if duringmixedmode: endmixedmultipart + endmultipart
         * else only endmultipart
         */
        if (data instanceof Attribute) {
            if (duringMixedMode) {
                InternalAttribute internal = new InternalAttribute(charset);
                internal.addValue("\r\n--" + multipartMixedBoundary + "--");
                multipartHttpDatas.add(internal);
                multipartMixedBoundary = null;
                currentFileUpload = null;
                duringMixedMode = false;
            }
            InternalAttribute internal = new InternalAttribute(charset);
            if (!multipartHttpDatas.isEmpty()) {
                // previously a data field so CRLF
                internal.addValue("\r\n");
            }
            internal.addValue("--" + multipartDataBoundary + "\r\n");
            // content-disposition: form-data; name="field1"
            Attribute attribute = (Attribute) data;
            internal.addValue(HttpHeaderNames.CONTENT_DISPOSITION + ": " + HttpHeaderValues.FORM_DATA + "; "
                    + HttpHeaderValues.NAME + "=\"" + attribute.getName() + "\"\r\n");

Subdomains

Frequently Asked Questions

What does addBodyHttpData() do?
addBodyHttpData() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java.
Where is addBodyHttpData() defined?
addBodyHttpData() is defined in codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java at line 439.
What does addBodyHttpData() call?
addBodyHttpData() calls 3 function(s): ErrorDataEncoderException, initMixedMultipart, length.
What calls addBodyHttpData()?
addBodyHttpData() is called by 3 function(s): addBodyAttribute, addBodyFileUpload, setBodyHttpDatas.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free