[
https://issues.apache.org/jira/browse/YETUS-541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16591821#comment-16591821
]
Sean Busbey commented on YETUS-541:
-----------------------------------
{code}
+## @description POST a file to a URL
+## @audience public
+## @stability stable
+## @replaceable no
+## @param url
+## @param filename
+## @param curl params array
+## @return exit code of curl; CURL_MESSAGE contains last (human
readable) error message
+function curl_post
+{
+ declare url
+ declare filename
+ declare -a auth
+ declare ec
+
+ url=$1
+ filename=$2
+ shift 2
+ auth=("$@")
+
+ if [[ ${#auth[@]} -gt 0 ]]; then
+ ${CURL} -X POST \
+ "${auth[@]}" \
+ -d @"${filename}" \
+ --silent --location \
+ "${url}" \
+ >/dev/null
+ else
+ CURL_MESSAGE="No authentication information provided."
+ return 22
+ fi
+
+ ec=$?
+
+ curl_message "${url}" "${filename}" "${ec}"
+
+ return ${ec}
+}
+
{code}
Shouldn't we only have this "no auth info" error if doing the post fails with a
HTTP 401? or maybe any returned 22 from curl?
> Introduce a general "fetch url" function to have common error handling for
> curl calls.
> --------------------------------------------------------------------------------------
>
> Key: YETUS-541
> URL: https://issues.apache.org/jira/browse/YETUS-541
> Project: Yetus
> Issue Type: Improvement
> Components: Test Patch
> Reporter: Mano Kovacs
> Assignee: Allen Wittenauer
> Priority: Major
> Fix For: 0.9.0
>
> Attachments: YETUS-541.00.patch, YETUS-541.01.patch
>
>
> Currently every plugin calls {{curl}} an handles (or does not handle) error
> individually. Proposing common fetch-url function that provides general error
> handling and later other common properties for HTTP calls.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)