j commited on
Commit
5a4097e
·
1 Parent(s): b2f2413

added debugging when status not found in http headers

Browse files
reascripts/ReaSpeech/source/ReaSpeechAPI.lua CHANGED
@@ -51,6 +51,7 @@ function ReaSpeechAPI:fetch_json(url_path, http_method, error_handler, timeout_h
51
  ' -s',
52
  ' -i',
53
  ' --http1.1',
 
54
  })
55
 
56
  app:debug('Fetch JSON: ' .. command)
@@ -124,6 +125,7 @@ function ReaSpeechAPI:fetch_large(url_path, http_method)
124
  ' -i ',
125
  ' -o "', output_file, '"',
126
  ' --http1.1',
 
127
  })
128
 
129
  app:debug('Fetch large: ' .. command)
@@ -169,6 +171,7 @@ function ReaSpeechAPI:post_request(url_path, data, file_path)
169
  ' -F ', self:_maybe_quote('audio_file=@"' .. file_path .. '"'),
170
  ' -i ',
171
  ' --http1.1 ',
 
172
  ' -o "', output_file, '"',
173
  })
174
 
@@ -199,6 +202,15 @@ function ReaSpeechAPI.http_status_and_body(response)
199
 
200
  local status = last_status_line:match("^HTTP/%d%.%d%s+(%d+)")
201
  if not status then
 
 
 
 
 
 
 
 
 
202
  return -1, 'Status not found in headers'
203
  end
204
 
@@ -210,6 +222,7 @@ function ReaSpeechAPI.http_status_and_body(response)
210
  return tonumber(status), table.concat(body, "\n")
211
  end
212
 
 
213
  function ReaSpeechAPI._split_curl_response(input)
214
  local line_iterator = ReaSpeechAPI._line_iterator(input)
215
  local chunk_iterator = ReaSpeechAPI._chunk_iterator(line_iterator)
 
51
  ' -s',
52
  ' -i',
53
  ' --http1.1',
54
+ ' --retry 5',
55
  })
56
 
57
  app:debug('Fetch JSON: ' .. command)
 
125
  ' -i ',
126
  ' -o "', output_file, '"',
127
  ' --http1.1',
128
+ ' --retry 5',
129
  })
130
 
131
  app:debug('Fetch large: ' .. command)
 
171
  ' -F ', self:_maybe_quote('audio_file=@"' .. file_path .. '"'),
172
  ' -i ',
173
  ' --http1.1 ',
174
+ ' --retry 5',
175
  ' -o "', output_file, '"',
176
  })
177
 
 
202
 
203
  local status = last_status_line:match("^HTTP/%d%.%d%s+(%d+)")
204
  if not status then
205
+ local headers_log = "Headers array (status parsing failed):\n"
206
+ for i, header_chunk in ipairs(headers) do
207
+ headers_log = headers_log .. string.format("Chunk %d:\n", i)
208
+ for j, header_line in ipairs(header_chunk) do
209
+ headers_log = headers_log .. string.format(" %s\n", header_line)
210
+ end
211
+ end
212
+ app:debug(headers_log)
213
+
214
  return -1, 'Status not found in headers'
215
  end
216
 
 
222
  return tonumber(status), table.concat(body, "\n")
223
  end
224
 
225
+
226
  function ReaSpeechAPI._split_curl_response(input)
227
  local line_iterator = ReaSpeechAPI._line_iterator(input)
228
  local chunk_iterator = ReaSpeechAPI._chunk_iterator(line_iterator)