web apps midterm 1 Flashcards

(69 cards)

1
Q

What does HTTP stand for?

A

Hypertext Transfer Protocol — stateless application-level protocol.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Difference between HTTP/1.1, HTTP/2, HTTP/3?

A

1.1 = text, one request per connection; 2 = binary, multiplexing, header compression; 3 = like 2 but over QUIC/UDP.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Safe & cacheable HTTP method?

A

GET.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

HTTP method used for actions, not cacheable, can cause side effects?

A

POST.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

URL components?

A

scheme://authority/path?query#fragment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Is HTTP stateful or stateless?

A

Stateless — each request is independent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the Host header specify?

A

Requested domain/authority.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the Accept header specify?

A

Content types the client prefers (e.g., text/html).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the Content-Type header specify?

A

MIME type of body (e.g., application/json).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the Set-Cookie header do?

A

Server asks client to store cookie.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Cache-Control: no-store means?

A

Don’t cache response anywhere.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the User-Agent header contain?

A

Client software info (browser name/version).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Accept-Encoding header means?

A

Compression formats client supports (e.g., gzip).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the ETag header?

A

Identifier for resource version (used with caching).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the Location header do?

A

New URL for redirects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the Referer header show?

A

URL of page that triggered the request.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Difference between If-Modified-Since and If-None-Match?

A

IMS = date/time check, INM = ETag check for cache validation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What does Connection: keep-alive mean?

A

Persistent HTTP/1.1 connection reused for multiple requests.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

HTTP status 200?

A

OK — request successful.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

HTTP status 301 vs 302 vs 303?

A

301 = moved permanently, 302 = temporary redirect, 303 = see other (GET next).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

HTTP status 304?

A

Not Modified — use cached copy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

HTTP status 400 / 403 / 404 / 500?

A

Bad request / Forbidden / Not found / Server error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Purpose of cookies?

A

Maintain state across stateless HTTP requests.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Secure cookie attribute?

A

Send cookie only over HTTPS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
HttpOnly cookie attribute?
JS cannot access cookie (mitigates XSS).
26
SameSite=Strict means?
Only send cookie on same-site requests.
27
What is a session token?
Random ID identifying a logged-in user session.
28
Max-Age vs Expires in cookies?
Max-Age = lifetime in seconds; Expires = exact date/time.
29
Path attribute in a cookie?
Restricts cookie to matching URL path.
30
Domain attribute in a cookie?
Specifies which hosts can receive the cookie.
31
SameSite=None requires what?
Secure attribute and HTTPS.
32
Goal of TLS?
Confidentiality, integrity, server authentication.
33
TLS Handshake phases?
Negotiation → Key exchange (ephemeral keys + HKDF) → Authentication (certificates).
34
What does the TLS record protocol do?
Encrypt + authenticate application data.
35
What is PKI?
Public Key Infrastructure — validates server certs via chain of trust.
36
What is forward secrecy in TLS?
Compromise of long-term keys doesn’t reveal past session keys (ephemeral keys).
37
How does TLS detect message tampering?
Authenticated encryption & sequence numbers.
38
What does a TLS certificate include?
Public key, domain names, validity dates, CA signature.
39
Who are root certificate authorities?
Trusted organizations pre-installed in browsers/OS.
40
What is a session ticket in TLS?
Token allowing faster session resumption.
41
SQL injection example?
' OR 1=1 -- bypasses WHERE clause.
42
Defense against SQL injection?
Prepared statements / parameterized queries.
43
What is second-order SQL injection?
Malicious input stored in DB is later used in a vulnerable query.
44
What is a UNION SQLi attack?
Append UNION SELECT ... to extract other tables’ data.
45
XSS types?
Reflected, Stored, DOM-based.
46
Defense against XSS?
Escape/encode output, validate input, Content Security Policy.
47
What is a CSRF attack?
Forces a logged-in user to unknowingly submit a request.
48
CSRF prevention?
Tokens in forms, SameSite cookies.
49
HSTS header does what?
Strict-Transport-Security: max-age=... forces HTTPS.
50
Strong password storage best practice?
Salt + slow hash (bcrypt/scrypt/Argon2).
51
MVC: Model?
Data & business logic (SQLAlchemy models).
52
MVC: View?
Jinja HTML templates shown to user.
53
MVC: Controller?
Flask routes handling HTTP requests & returning responses.
54
Flask decorator @bp.route("/path") does what?
Maps URL to controller function.
55
How to read form data in Flask?
request.form.get("field_name")
56
What does render_template() do?
Renders a Jinja HTML file with passed variables.
57
Purpose of db.session.commit()?
Saves changes to the database.
58
How to fetch one row by primary key in SQLAlchemy?
db.session.get(Model, id) or db.get_or_404(Model, id).
59
What is a relationship in SQLAlchemy?
Python-level link between tables (e.g., User.posts).
60
Why use ORM instead of raw SQL?
Safer, more readable, avoids SQL injection.
61
What is in the Flask request object?
Data about current HTTP request (headers, form, JSON, etc.).
62
What happens if a controller aborts with 404?
Returns an HTTP 404 Not Found response.
63
Block vs inline HTML elements?
Block starts new line (div, p); inline flows (span, em).
65
does what?
Sends hidden data to server.
66
CSS selector div > p selects?
p elements that are direct children of a div.
67
CSS selector p + span selects?
span immediately after a p.
68
CSS units em vs rem?
em = relative to parent font size; rem = relative to root font size.
69
How to include external CSS?