Should cookie values be URL encoded?

Yes. While it’s not required per the spec, the following is mentioned in RFC6265 (emphasis is in the original document, not added) To maximize compatibility with user agents, servers that wish to store arbitrary data in a cookie-value SHOULD encode that data, for example, using Base64 [RFC4648]. In my experience, most web frameworks and libraries … Read more

Avoid caching of the http responses

Server-side cache control headers should look like: Expires: Tue, 03 Jul 2001 06:00:00 GMT Last-Modified: {now} GMT Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate Avoid rewriting URLs on the client because it pollutes caches, and causes other weird semantic issues. Furthermore: Use one Cache-Control header (see rfc 2616) because behaviour with multiple entries is undefined. Also the … Read more

How to read client IP addresses from HTTP requests behind Kubernetes services?

As of 1.5, if you are running in GCE (by extension GKE) or AWS, you simply need to add an annotation to your Service to make HTTP source preservation work. … kind: Service metadata: annotations: service.beta.kubernetes.io/external-traffic: OnlyLocal … It basically exposes the service directly via nodeports instead of providing a proxy–by exposing a health probe … Read more

Can a http server detect that a client has cancelled their request?

While @Oded is correct that HTTP is stateless between requests, app servers can indeed detect when the underlying TCP/IP connection has broken for the request being processed. Why is this? Because TCP is a stateful protocol for reliable connections. A common technique for .Net web apps processing a resource intensive request is to check Response.IsClientConnected … Read more

How to make XMLHttpRequest cross-domain withCredentials, HTTP Authorization (CORS)?

I’ve written an article with a complete CORS setup. I found several issues that can result in this problem: The Access-Control-Allow-Origin cannot be a wildcard if credentials are being used. It’s easiest just to copy the Origin header of the request to this field. It’s entirely unclear why the standard would disallow a wildcard. Firefox … Read more

HTTPS Proxy Server in node.js

Solutions barely exist for this, and the documentation is poor at best for supporting both on one server. The trick here is to understand that client proxy configurations may send https requests to an http proxy server. This is true for Firefox if you specify an HTTP proxy and then check “same for all protocols”. … Read more