http

typescript
export interface RetryOptions {
  retries: number;
  baseMs: number;
  maxMs: number;
  signal?: AbortSignal;
  onRetry?: (attempt: number, delay: number, err: unknown) => void;

Exponential backoff with jitter for retries

typescript reliability retry
by codesnips 2 tabs
go
package deps

import (
  "net"
  "net/http"
  "time"

HTTP client tuned for production: timeouts, transport, and connection reuse

go http client
by Leah Thompson 1 tab
go
package api

import (
  "io"
  "net/http"
  "os"

Safe multipart uploads using temp files (bounded memory)

go http uploads
by Leah Thompson 1 tab
go
package deps

import (
  "crypto/tls"
  "crypto/x509"
  "net/http"

mTLS client configuration with custom root CA pool

go security tls
by Leah Thompson 1 tab
typescript
import type { IncomingMessage, ServerResponse } from "http";

const MIN_BYTES = 1024;

const INCOMPRESSIBLE = /^(image|video|audio)\/|application\/(zip|gzip|x-brotli|pdf|octet-stream)/i;

Response compression (only when it helps)

performance http express
by codesnips 3 tabs
javascript
// Basic GET request
fetch('https://api.example.com/users')
  .then(response => {
    console.log('Status:', response.status);
    console.log('OK:', response.ok);
    return response.json();

Fetch API for HTTP requests and AJAX communication

javascript fetch api
by Alex Chang 1 tab
typescript
import { NodeSDK } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { Resource } from '@opentelemetry/resources';
import {

OpenTelemetry tracing for Node HTTP

observability tracing opentelemetry
by codesnips 3 tabs
go
package api

import (
  "encoding/json"
  "errors"
  "io"

Streaming JSON decoding with DisallowUnknownFields

go http json
by Leah Thompson 1 tab
go
package debughttp

import (
  "context"
  "crypto/tls"
  "net/http"

HTTPtrace to debug DNS/connect/TLS timing in production-like runs

go http client
by Leah Thompson 1 tab
go
package deps

import (
  "context"
  "net/http"

Token bucket rate limiter for outbound calls

go rate-limit http
by Leah Thompson 1 tab
typescript
import express from 'express';
import cookieParser from 'cookie-parser';
import { issueCsrfToken, csrfProtection } from './csrf';
import { transfersRouter } from './routes/transfers';

const app = express();

CSRF protection with double-submit cookie

security express csrf
by codesnips 3 tabs
typescript
import { Agent as HttpAgent } from 'http';
import { Agent as HttpsAgent } from 'https';

const shared = {
  keepAlive: true,
  keepAliveMsecs: 1_000,

HTTP keep-alive agent for outbound calls

http performance nodejs
by codesnips 3 tabs