Challenge - 5 Problems
Link Header Navigator
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this HTTP Link header parsing?
Given the HTTP Link header below, what is the value of the 'next' URL extracted?
Rest API
Link: <https://api.example.com/items?page=2>; rel="next", <https://api.example.com/items?page=5>; rel="last"
Attempts:
2 left
💡 Hint
Look for the rel="next" link in the header.
✗ Incorrect
The Link header contains multiple URLs with rel attributes. The URL with rel="next" is the one for the next page, which is page=2.
🧠 Conceptual
intermediate1:30remaining
What is the purpose of the 'rel' attribute in Link headers?
In HTTP Link headers used for navigation, what does the 'rel' attribute specify?
Attempts:
2 left
💡 Hint
Think about how the client knows what the link means.
✗ Incorrect
The 'rel' attribute describes the relationship between the current resource and the linked resource, such as 'next', 'prev', or 'last'.
🔧 Debug
advanced2:00remaining
Why does this Link header cause a parsing error?
Consider this Link header:
Link: rel="next", ; rel="last"
Why does it cause a parsing error?
Attempts:
2 left
💡 Hint
Check the syntax between the URL and the rel attribute.
✗ Incorrect
Each link must separate the URL and its parameters with a semicolon. The first link misses the semicolon before rel="next".
🚀 Application
advanced2:30remaining
How to include multiple navigation links in a single Link header?
You want to provide 'first', 'prev', 'next', and 'last' navigation links in one HTTP Link header. Which is the correct format?
Attempts:
2 left
💡 Hint
Look for correct separators and syntax between links.
✗ Incorrect
Multiple links in a Link header are separated by commas, and each link's parameters follow a semicolon after the URL.
❓ Predict Output
expert3:00remaining
What is the output of this Python code parsing Link headers?
Given the Python code below that parses an HTTP Link header, what is the output printed?
Rest API
link_header = '<https://api.example.com/items?page=3>; rel="next", <https://api.example.com/items?page=1>; rel="prev"' links = {} for part in link_header.split(','): url_part, rel_part = part.strip().split(';') url = url_part.strip()[1:-1] rel = rel_part.strip().split('=')[1].strip('"') links[rel] = url print(links.get('prev'))
Attempts:
2 left
💡 Hint
Check how the dictionary keys are assigned and what is printed.
✗ Incorrect
The code splits the header by commas, extracts URLs and rel values, stores them in a dictionary, then prints the URL for 'prev'.