Code Explainers
Code explainers tagged #http
java
public static Map<String, String> parseCookieHeader(String header) { Map<String, String> cookies = new LinkedHashMap<>(); if (header == null || header.isBlank()) { return cookies;
Parsing an HTTP Cookie header in Java
string-parsing
http
url-decoding
Intermediate
6 steps
go
package httputil import ( "net"
Safely extracting the real client IP in Go
security
http
ip-spoofing
Intermediate
7 steps
go
package api import ( "encoding/json"
Safely decoding JSON in a Go HTTP handler
http
json-decoding
input-validation
Intermediate
8 steps
typescript
interface ContentRange { unit: string; start: number; end: number;
Parsing HTTP Content-Range headers in TypeScript
regex
parsing
validation
Intermediate
8 steps
typescript
interface ParsedCookie { name: string; value: string; domain?: string;
Parsing a Set-Cookie header in TypeScript
parsing
string-manipulation
type-safety
Intermediate
9 steps
python
from functools import wraps from flask import request, jsonify
A parameterized query-param decorator in Flask
decorators
validation
type-casting
Intermediate
8 steps
javascript
const express = require('express'); const cors = require('cors'); const app = express();
Configuring a CORS allowlist in Express
cors
middleware
security
Intermediate
8 steps
typescript
import { Component, inject } from '@angular/core'; import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { finalize } from 'rxjs';
A reactive signup form in Angular
reactive-forms
validation
dependency-injection
Intermediate
10 steps
go
func (h *ReportHandler) ExportTransactions(w http.ResponseWriter, r *http.Request) { ctx := r.Context() from, to, err := parseDateRange(r.URL.Query())
Streaming a CSV export in Go
streaming
http
csv
Intermediate
8 steps
php
<?php namespace App\Http;
HTTP content negotiation in PHP
http
content-negotiation
parsing
Intermediate
9 steps
php
<?php namespace App\Http\Middleware;
Caching HTTP responses with Laravel middleware
middleware
caching
http
Intermediate
8 steps
rust
use axum::{ body::{Body, Bytes}, extract::Request, http::StatusCode,
Logging request and response sizes in Axum
middleware
http
streaming-bodies
Advanced
8 steps
go
package middleware import ( "net/http"
Per-IP write rate limiting in Gin
rate-limiting
middleware
concurrency
Intermediate
8 steps
python
import asyncio from dataclasses import dataclass import aiohttp
Bounded-concurrency HTTP fetching with asyncio
async
concurrency
semaphore
Intermediate
8 steps
go
package middleware import ( "net/http"
A content-type guard middleware in Gin
middleware
closures
http
Intermediate
7 steps
go
package middleware import ( "compress/gzip"
How gzip HTTP middleware works in Go
middleware
compression
object-pooling
Intermediate
7 steps
rust
use std::collections::HashMap; #[derive(Debug)] pub struct RequestHead {
Parsing an HTTP request head in Rust
parsing
error-handling
iterators
Intermediate
9 steps
go
func UploadChunk(c *gin.Context) { uploadID := c.Param("uploadID") if !validUploadID.MatchString(uploadID) { c.JSON(http.StatusBadRequest, gin.H{"error": "invalid upload id"})
Resumable chunked uploads in Gin
file-upload
content-range
streaming
Advanced
9 steps