Video summary
pwn.college - Talking Web - URLs and Encoding
Main summary
Key takeaways
Main ideas and concepts
-
What a URL is and its components
- A URL (Uniform Resource Locator) is made up of:
- Scheme (protocol, e.g.,
http) - Host (domain/server, e.g.,
example.com) - Port (service endpoint on the server, e.g.,
80for HTTP) - Path (specific resource, e.g.,
/cat.gif) - Query (extra parameters for the resource, e.g., width/height)
- Fragment (client-side info; not sent to the server)
- Scheme (protocol, e.g.,
- A URL (Uniform Resource Locator) is made up of:
-
Example URL purpose
- Demonstrates a request to retrieve a resource like a GIF with additional parameters:
- width
- height
- playback start time (described as part of client-specific handling via fragment)
- Demonstrates a request to retrieve a resource like a GIF with additional parameters:
-
How HTTP request parsing relates to URL structure
- The request line format:
METHOD SP REQUEST-URI SP HTTP-VERSION CRLF
- Problem scenario: if the request URI contains a literal space (e.g.,
hello world), the server may interpret it as delimiters and therefore:- mis-parse the request
- think the client is speaking invalid/bad HTTP
- return a “bad request” error
- The request line format:
-
Solution: URL encoding
- Spaces and other unsafe/unprintable/reserved characters must be encoded so the request parser stays in sync.
- HTTP allows spaces in resources, but they must be encoded in the URL.
- Encoding format:
%+ two hexadecimal digits
- Examples:
- Space →
%20 #→%23/→%2F?→%3F- (Also noted: characters like
Acan be encoded optionally, e.g.,A→%41)
- Space →
- Resulting behavior:
- The server can correctly parse the request and return the intended resource (e.g.,
hello worldaccessed ashello%20world).
- The server can correctly parse the request and return the intended resource (e.g.,
-
Encoding methods / content types for sending request data
- The lecture transitions to how data is encoded in the body of requests, especially for POST-like interactions.
application/x-www-form-urlencoded- Used for typical HTML form submissions.
- Structure:
key=valuepairs- multiple fields separated by
&
- Example described:
name=Connor
application/json- Used for sending structured, hierarchical data.
- Structure:
- a JSON object with keys and values
- Example shape:
{ "key": "value" }(specifically{ "name": "Connor" }in the description)
- Why choose one over the other
- Form URL encoded: convenient for simple form field submissions.
- JSON: better for complex nested data and modern API communication.
- Mentions JSON-based REST APIs
- Clients make remote computation requests over HTTP.
- Responses return data blobs (not HTML pages) that the client parses.
- JSON is commonly used for this.
Methodology / instruction-style details (detailed bullets)
URL structure to use in requests
Build the URL using these parts:
- Scheme: select the protocol (e.g.,
http) - Host: domain where the resource lives (e.g.,
example.com) - Port: choose the server port (HTTP default
80; may be omitted when standard) - Path: specify the target resource (e.g.,
/cat.gif) - Query: append key-value style parameters for resource behavior (e.g.,
width=256&height=256) - Fragment: add client-side-only reference (not sent to the server)
Fixing spaces / unsafe characters in a resource name (URL encoding)
- When a resource contains characters like spaces (or reserved/unprintable chars), do not place them literally in the URL.
- Encode each required character using:
'%'+hex-digit+hex-digit
- Apply examples:
- Replace space with
%20 - Replace
#with%23 - Replace
/with%2F - Replace
?with%3F
- Replace space with
- Encode the problematic part of the request URI so:
- the server’s HTTP parser does not misinterpret delimiters
- the request is accepted and the correct resource is returned
Selecting request body content type (for POST-style data)
- If submitting from an HTML form:
- use
application/x-www-form-urlencoded - encode body as:
field1=value1&field2=value2...
- use
- If sending structured/hierarchical data:
- use
application/json - encode body as a JSON object:
{ "key": "value", ... }
- use
Speakers / sources featured
- No named speaker is identified in the subtitles.
- Referenced standards / documents:
- RFC 1945 (discussed in the context of HTTP request URI formatting and “bad request” behavior)
- Referenced character encoding reference:
- ASCII chart (used to determine hexadecimal values for URL encoding)