← 返回 atlassian 的题目列表Fetch a list of URLs sequentially and return responses
类型:online_judge
Given a list of URLs, send an HTTP GET request to each URL sequentially and return the result for every request.
Requirements
Input: a list of URL strings.
Output: a list of results in the same order as input. Each result includes:
url: the original URL
status: HTTP status code (use 0 or your own error code on failure, and put details in error)
body: response body as text (empty string on failure is acceptable)
error: optional error message
Must be sequential: start the next request only after the previous one finishes.
Handle network errors/timeouts; one failed URL must not abort the entire run.
Constraints
Number of URLs n: 1 ≤ n ≤ 50
Single response body size: ≤ 1 MB
Example Input: ["https://example.com", "https://httpstat.us/404"] Output: [{url:"https://example.com", status:200, body:"..."}, {url:"https://httpstat.us/404", status:404, body:"..."}]
Test cases (illustrative) Because this depends on real networking, use a mock server/stubs in an interview setting to assert ordering and output shape.
Example
Input
(mock) ["http://mock/ok", "http://mock/404"]
Output
[{url:".../ok", status:200, body:"OK"}, {url:".../404", status:404, body:"Not Found"}]