File tree 1 file changed +12
-10
lines changed
1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -154,24 +154,26 @@ async sub problem {
154
154
my $response = shift -> result;
155
155
156
156
$answerJWTresponse -> {status } = int ($response -> code);
157
- if ($response -> is_success) {
157
+ # answerURL responses are expected to be JSON
158
+ if ($response -> json) {
159
+ # munge data with default response object
160
+ $answerJWTresponse = { %$answerJWTresponse , %{$response -> json} };
161
+ } else {
162
+ # otherwise throw the whole body as the message
158
163
$answerJWTresponse -> {message } = $response -> body;
159
164
}
160
- elsif ($response -> is_error) {
161
- $answerJWTresponse -> {message } = ' [' . $c -> logID . ' ] ' . $response -> message;
162
- }
163
-
164
- $answerJWTresponse -> {message } =~ s / "/ \\ "/ g ;
165
- $answerJWTresponse -> {message } =~ s / '/ \' / g ;
166
165
})->
167
166
catch(sub {
168
- my $response = shift ;
169
- $c -> log -> error($response );
167
+ my $err = shift ;
168
+ $c -> log -> error($err );
170
169
171
170
$answerJWTresponse -> {status } = 500;
172
- $answerJWTresponse -> {message } = ' [' . $c -> logID . ' ] ' . $response ;
171
+ $answerJWTresponse -> {message } = ' [' . $c -> logID . ' ] ' . $err ;
173
172
});
173
+
174
174
$answerJWTresponse = encode_json($answerJWTresponse );
175
+ # this will become a string literal, so single-quote characters must be escaped
176
+ $answerJWTresponse =~ s / '/ \\ '/ g ;
175
177
$c -> log -> info(" answerJWT response " .$answerJWTresponse );
176
178
177
179
$ww_return_hash -> {renderedHTML } =~ s / JWTanswerURLstatus/ $answerJWTresponse / g ;
You can’t perform that action at this time.
0 commit comments