Skip to content

Commit

Permalink
Merge pull request #465 from jasonc/http-status-code-change-fix
Browse files Browse the repository at this point in the history
Allow for HTTP 2 Status Codes.
  • Loading branch information
andreafabrizi committed Mar 12, 2019
2 parents b362ebf + 3fd037e commit a3df727
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions dropbox_uploader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ function check_http_response
esac

#Checking response file for generic errors
if grep -q "HTTP/1.1 400" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 400" "$RESPONSE_FILE"; then
ERROR_MSG=$(sed -n -e 's/{"error": "\([^"]*\)"}/\1/p' "$RESPONSE_FILE")

case $ERROR_MSG in
Expand Down Expand Up @@ -572,7 +572,7 @@ function db_simple_upload_file
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
print "DONE\n"
else
print "FAILED\n"
Expand Down Expand Up @@ -641,7 +641,7 @@ function db_chunked_upload_file
#check_http_response not needed, because we have to retry the request in case of error

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
let OFFSET=$OFFSET+$CHUNK_REAL_SIZE
UPLOAD_ERROR=0
if [[ $VERBOSE != 1 ]]; then
Expand Down Expand Up @@ -675,7 +675,7 @@ function db_chunked_upload_file
#check_http_response not needed, because we have to retry the request in case of error

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
UPLOAD_ERROR=0
break
else
Expand Down Expand Up @@ -859,7 +859,7 @@ function db_download_file
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
print "DONE\n"
else
print "FAILED\n"
Expand Down Expand Up @@ -929,7 +929,7 @@ function db_account_info
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then

name=$(sed -n 's/.*"display_name": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
echo -e "\n\nName:\t\t$name"
Expand Down Expand Up @@ -960,7 +960,7 @@ function db_account_space
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then

quota=$(sed -n 's/.*"allocated": \([0-9]*\).*/\1/p' "$RESPONSE_FILE")
let quota_mb=$quota/1024/1024
Expand Down Expand Up @@ -1003,7 +1003,7 @@ function db_delete
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
print "DONE\n"
else
print "FAILED\n"
Expand Down Expand Up @@ -1032,7 +1032,7 @@ function db_move
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
print "DONE\n"
else
print "FAILED\n"
Expand Down Expand Up @@ -1061,7 +1061,7 @@ function db_copy
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
print "DONE\n"
else
print "FAILED\n"
Expand All @@ -1080,9 +1080,9 @@ function db_mkdir
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
print "DONE\n"
elif grep -q "^HTTP/1.1 403 Forbidden" "$RESPONSE_FILE"; then
elif grep -q "^HTTP/[12].* 403" "$RESPONSE_FILE"; then
print "ALREADY EXISTS\n"
else
print "FAILED\n"
Expand Down Expand Up @@ -1121,7 +1121,7 @@ function db_list_outfile
CURSOR=$(sed -n 's/.*"cursor": *"\([^"]*\)".*/\1/p' "$RESPONSE_FILE")

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then

#Extracting directory content [...]
#and replacing "}, {" with "}\n{"
Expand Down Expand Up @@ -1244,14 +1244,14 @@ function db_monitor_nonblock
$CURL_BIN $CURL_ACCEPT_CERTIFICATES -X POST -L -s --show-error --globoff -i -o "$RESPONSE_FILE" --header "Authorization: Bearer $OAUTH_ACCESS_TOKEN" --header "Content-Type: application/json" --data "{\"path\": \"$DIR_DST\",\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false}" "$API_LIST_FOLDER_URL" 2> /dev/null
check_http_response

if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then

local CURSOR=$(sed -n 's/.*"cursor": *"\([^"]*\)".*/\1/p' "$RESPONSE_FILE")

$CURL_BIN $CURL_ACCEPT_CERTIFICATES -X POST -L -s --show-error --globoff -i -o "$RESPONSE_FILE" --header "Content-Type: application/json" --data "{\"cursor\": \"$CURSOR\",\"timeout\": ${TIMEOUT}}" "$API_LONGPOLL_FOLDER" 2> /dev/null
check_http_response

if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
local CHANGES=$(sed -n 's/.*"changes" *: *\([a-z]*\).*/\1/p' "$RESPONSE_FILE")
else
ERROR_MSG=$(grep "Error in call" "$RESPONSE_FILE")
Expand Down Expand Up @@ -1333,7 +1333,7 @@ function db_share
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
print " > Share link: "
SHARE_LINK=$(sed -n 's/.*"url": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
echo "$SHARE_LINK"
Expand All @@ -1351,7 +1351,7 @@ function get_Share
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
print " > Share link: "
SHARE_LINK=$(sed -n 's/.*"url": "\([^"]*\).*/\1/p' "$RESPONSE_FILE")
echo "$SHARE_LINK"
Expand All @@ -1375,7 +1375,7 @@ function db_search
check_http_response

#Check
if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then
if grep -q "^HTTP/[12].* 200" "$RESPONSE_FILE"; then
print "DONE\n"
else
print "FAILED\n"
Expand Down

0 comments on commit a3df727

Please sign in to comment.