@sun-asterisk/sunlint 1.3.14 → 1.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/upload-service.js +31 -9
- package/package.json +1 -1
package/core/upload-service.js
CHANGED
|
@@ -89,25 +89,45 @@ class UploadService {
|
|
|
89
89
|
const fileName = path.basename(filePath);
|
|
90
90
|
const timeout = options.timeout || 30; // 30 seconds default timeout
|
|
91
91
|
|
|
92
|
-
// Build curl command
|
|
92
|
+
// Build curl command with status code output
|
|
93
93
|
const curlCommand = this.buildCurlCommand(filePath, apiUrl, fileName, timeout);
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
|
-
// Execute curl command
|
|
96
|
+
// Execute curl command with write-out to get status code
|
|
97
97
|
const output = execSync(curlCommand, {
|
|
98
98
|
encoding: 'utf8',
|
|
99
99
|
maxBuffer: 1024 * 1024, // 1MB buffer
|
|
100
100
|
timeout: timeout * 1000 // Convert to milliseconds
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
// Parse response
|
|
104
|
-
|
|
103
|
+
// Parse response with headers included (-i flag)
|
|
104
|
+
// Output format: "HTTP/1.1 200 OK\nHeaders...\n\nResponse Body"
|
|
105
|
+
const lines = output.trim().split('\n');
|
|
106
|
+
|
|
107
|
+
// Find the status line (first line starting with HTTP)
|
|
105
108
|
let statusCode = null;
|
|
109
|
+
const statusLine = lines.find(line => line.startsWith('HTTP/'));
|
|
110
|
+
if (statusLine) {
|
|
111
|
+
const statusMatch = statusLine.match(/HTTP\/[\d.]+\s+(\d{3})/);
|
|
112
|
+
if (statusMatch) {
|
|
113
|
+
statusCode = parseInt(statusMatch[1]);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Find response body (after empty line separating headers from body)
|
|
118
|
+
let response = '';
|
|
119
|
+
let foundEmptyLine = false;
|
|
120
|
+
for (const line of lines) {
|
|
121
|
+
if (foundEmptyLine) {
|
|
122
|
+
response += (response ? '\n' : '') + line;
|
|
123
|
+
} else if (line.trim() === '') {
|
|
124
|
+
foundEmptyLine = true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
106
127
|
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
statusCode = parseInt(statusMatch[1]);
|
|
128
|
+
// If no empty line found, assume entire output is response
|
|
129
|
+
if (!foundEmptyLine) {
|
|
130
|
+
response = output.trim();
|
|
111
131
|
}
|
|
112
132
|
|
|
113
133
|
return {
|
|
@@ -144,7 +164,9 @@ class UploadService {
|
|
|
144
164
|
}
|
|
145
165
|
|
|
146
166
|
curlOptions.push(
|
|
147
|
-
`--data @"${filePath}"`,
|
|
167
|
+
`--data-binary @"${filePath}"`,
|
|
168
|
+
'-i', // Include response headers in output
|
|
169
|
+
'-s', // Silent mode (no progress meter)
|
|
148
170
|
`"${apiUrl}"`
|
|
149
171
|
);
|
|
150
172
|
|
package/package.json
CHANGED