Class RepeatedField
application/x-www-form-urlencoded or a multipart/form-data body alike.
Stapler keeps one value per name for a multipart body: RequestImpl parses the
parts into a map keyed by field name, so a repeated field keeps only its last part. Neither
getParameterValues nor getFileItem2 can return the others, and the body
stream has already been consumed by then (core may have parsed it during dispatch, before any
plugin code). So for a multipart request the json blob is read as well. f:form
posts that blob with every submission, and Stapler parses it from the same body.
The rule (D-37):
- multipart, and the blob holds string values for the field: those values, in their order,
and nothing else. The raw part is not added: it is one of the blob's values for the rendered
form, and Stapler decodes a part without a charset as ISO-8859-1, so a non-ASCII value would
come back garbled (UTF-8
山田read aså±±ç°) next to the blob's intact copy. - multipart without a blob, or a blob without string values for the field (for example the
boolean array of checkboxes without
json): the raw part, read as UTF-8 whereasTyped(org.kohsuke.stapler.StaplerRequest2, java.lang.String)allows it (R4-03), else as Stapler decoded it. - urlencoded:
getParameterValuesand nothing else, as before.
R4-03: a single plain text field (text(org.kohsuke.stapler.StaplerRequest2, java.lang.String)) follows the same rule: the blob's string
value when the multipart body carries one, else the part read as UTF-8 where allowed.
Nothing here parses a body that the caller has not let be parsed already. The blob is read
only when the request is multipart and carries a non-empty json field, and only after
getParameter, which parses the body in the first place. Callers read fields only after
their permission (and, for the run request, D-72 size) checks. A blob that is not a JSON object
is ignored, so the raw part is used as before. These are values only: the caller validates them.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisMultipart(org.kohsuke.stapler.StaplerRequest2 req) Whether Stapler reads this request's fields from a parsed multipart body (its own test).static String[]parameterValues(org.kohsuke.stapler.StaplerRequest2 req, String field) R4-03:getParameterValues(field)with the value of the multipart part read as UTF-8 whereasTyped(org.kohsuke.stapler.StaplerRequest2, java.lang.String)allows it.static StringR4-03: the value of the plain text fieldfieldas the user typed it, ornullwhen the request has no such field.
-
Method Details
-
isMultipart
public static boolean isMultipart(org.kohsuke.stapler.StaplerRequest2 req) Whether Stapler reads this request's fields from a parsed multipart body (its own test). -
values
public static List<String> values(org.kohsuke.stapler.StaplerRequest2 req, @CheckForNull net.sf.json.JSONObject formData, String field) - Parameters:
req- the current requestformData- the parsedjsonblob when the caller already has it, otherwisenull(for a multipart request it is then read from the request)field- the field name, also the key of the value in the blob's top-level object- Returns:
- the submitted values in submission order, possibly empty, never
null
-
text
R4-03: the value of the plain text fieldfieldas the user typed it, ornullwhen the request has no such field. On a multipart body thejsonblob's string value for the field wins when there is one (as invalues(org.kohsuke.stapler.StaplerRequest2, net.sf.json.JSONObject, java.lang.String)), else Stapler's value of the part asasTyped(org.kohsuke.stapler.StaplerRequest2, java.lang.String)reads it; on any other bodygetParameter, unchanged. -
parameterValues
@CheckForNull public static String[] parameterValues(org.kohsuke.stapler.StaplerRequest2 req, String field) R4-03:getParameterValues(field)with the value of the multipart part read as UTF-8 whereasTyped(org.kohsuke.stapler.StaplerRequest2, java.lang.String)allows it. For a multipart body Stapler answers the query string's values followed by the part's value, so the last element is the part's; any other body is answered unchanged.
-