mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
Fix responses logging without any content
This commit is contained in:
+9
-6
@@ -67,17 +67,25 @@ func retryRequest(ctx context.Context, reqFunc func(context.Context, string) (*r
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
start := time.Now()
|
||||
resp, err := retryClient.Do(req)
|
||||
end := time.Now()
|
||||
|
||||
// Unwrap the body here so that we could log stuff correctly
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
audit.LogAPIRoundTrip(audit.APIRequestSpan{
|
||||
RequestId: request_context.GetFromContext(ctx).RequestId,
|
||||
Response: resp,
|
||||
Error: err,
|
||||
Method: req.Method,
|
||||
Token: tokenValue,
|
||||
Body: "",
|
||||
Body: string(body),
|
||||
StartTime: start,
|
||||
EndTime: end,
|
||||
})
|
||||
@@ -86,11 +94,6 @@ func retryRequest(ctx context.Context, reqFunc func(context.Context, string) (*r
|
||||
if userToken == "" && !isPost {
|
||||
tokenManager.MarkTokenStatus(token, token_manager.Good)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SimpleHTTPResponse{
|
||||
StatusCode: resp.StatusCode,
|
||||
Body: string(body),
|
||||
|
||||
Reference in New Issue
Block a user