Skip to content
tezvyn:
Menu

Http

50 bites tagged Http: interview questions with model answers, and 60-second explainers.

Test yourself: Top 30 Http interview questions →Multiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.
Node.js & Express1 min read

HTTP request-response versus WebSocket connections?

HTTP is request-initiated, pull-based, client waits for response. WebSocket is persistent, bidirectional, either side sends data anytime.

Node.js & Express1 min read

Custom Error classes and centralized handling

Custom Error subclasses carry a statusCode and flag, the central handler inspects instanceof or statusCode to set the HTTP code and JSON shape, defaulting unknown errors to 500.

Node.js & Express1 min read

Basic presence validation on a POST login route

Ensure the JSON body parser runs, destructure email and password from req.body, return 400 early if either is missing, then proceed.

Node.js & Express1 min read

res.send vs res.json vs res.end

Send is flexible and sets content type by type, json serializes and sets JSON content type, end is the raw http terminator with no body helpers.

Node.js & Express1 min read

Minimal Express Hello World server

Import express, create an app, define app.get on the root sending a response, call app.listen on a port.

Node.js & Express1 min read

http.Agent and connection pooling

The agent pools and keeps sockets alive, avoiding repeated TCP and TLS handshakes, controlled by keepAlive and maxSockets.

Node.js & Express1 min read

Reading a POST body from the request stream

Body arrives in chunks via data events, accumulate them, on the end event concatenate and JSON.parse inside try/catch.

Node.js & Express1 min read

Minimal HTTP server with the http module

CreateServer with a request listener, set status and Content-Type, end the response, call listen on 3000.

Go & Rust1 min read

Logging middleware wrapping an http.Handler in Go

Middleware has signature func(http.Handler) http.Handler, records start time, calls next.ServeHTTP, then logs method, URL, and elapsed duration; chaining works because the wrapper is itself a…

Go & Rust1 min read

In-memory rate limiter middleware in Go

Use a token-bucket limiter (golang.org/x/time/rate), guard a per-client map with sync.Mutex, wrap http.Handler so requests over the limit get 429.

Go & Rust1 min read

Structuring a Go CLI that fetches a URL

Parse args with the flag package, http.Get the URL, check err and status, defer resp.Body.Close, copy body to stdout, exit non-zero on failure.

Android & Kotlin2 min read

Difference between @Path and @Query in Retrofit with example URLs

Tests Retrofit URL construction. @Path fills a path template like /users/{user}/repos with "octocat" to make /users/octocat/repos. @Query appends ?q=retrofit to /search/repos. Red flag: claiming @Query changes the path.

Android & Kotlin2 min read

How would you use Retrofit to GET /posts/{id} and key components?

This checks your understanding of Retrofit's three-layer setup. You need a data class for JSON parsing, an interface with @GET and @Path, and a Retrofit.Builder with baseUrl and a converter.

Vue, Angular & Svelte2 min read

Implement an async Angular validator with HTTP and PENDING feedback

Tests Angular async validator lifecycle and HTTP race conditions. A strong candidate returns an Observable from AsyncValidatorFn, lets Angular set PENDING automatically, debounces input, and binds control.pending in the template.

TypeScript & Web APIs2 min read

When does fetch trigger a CORS preflight, and what POST is complex?

Tests whether you know the simple-request boundary. A strong answer names the three safe POST content-types and gives a cross-origin POST with application/json plus a custom header like Authorization.

TypeScript & Web APIs2 min read

Write a createUser function that POSTs JSON via fetch

Precise fetch configuration for JSON POST requests. A strong answer names method POST, headers Content-Type application/json, and body JSON.stringify(data) with return typing. Red flag: passing the raw object as body or omitting headers.

TypeScript & Web APIs2 min read

How would you modify fetch to handle HTTP error statuses?

Verify response.ok in then and throw if false, then catch network failures separately.

React & Next.js2 min read

How do you handle 404s in React Router and Next.js App Router?

Tests client versus server routing architecture. React Router uses a wildcard route returning HTTP 200 by default; Next.js App Router uses not-found.js for server-rendered 404s. Red flag: confusing the two routers or ignoring status code semantics.

Flutter & Dart2 min read

Structure a POST request to send a Dart object as JSON

Set Content-Type application/json, serialize to Map via toJson, encode with dart:convert jsonEncode, and pass the string as body.

Flutter & Dart2 min read

Make a GET request with http and parse JSON in Dart

Practical Dart async networking with package:http and dart:convert. Import http, await get(Uri.parse(url)), verify statusCode is 200, then jsonDecode(response.body) as List<Map<String, dynamic>>. Skipping status checks or decoding without a cast.

Data Science & Analytics2 min read

How do you fetch JSON from a REST API and parse it?

This tests practical fluency with HTTP mechanics and JSON deserialization. A strong answer names the method, URL, and headers; checks the status code; then parses with r.json() or json.loads. A red flag is skipping error handling or confusing GET with POST.

Content & Copywriting2 min read

Draft a JSON error response for an invalid authentication token

Tests your ability to standardize API error contracts with RFC 7807. A strong answer returns 401 with type, title, detail, and instance, plus an actionable fix like re-authenticating. Red flag: 403, echoing the token, or exposing stack traces.

Vue, Angular & Svelte2 min read

Angular HttpInterceptor: A Pipeline for API Requests

Think of an HttpInterceptor as a pipeline for every API call, letting you inspect or modify requests and responses globally. Use it to automatically add auth headers or show a loading spinner.

Vue, Angular & Svelte2 min read

Angular HttpClient: Your App's API Connector

Angular's HttpClient turns network requests into RxJS Observables. Use it to fetch data or submit forms. The footgun: a request is never sent until you subscribe to the Observable it returns, a common mistake for beginners.

Get Http bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon