Remove http referer

As of 2015 this is how you prevent sending the Referer header: Just add this to the head section of the web page: <meta name=”referrer” content=”no-referrer” /> This works both for links and for Ajax requests made by JavaScript code on the page. Other valid meta options include: <meta name=”referrer” content=”unsafe-url” /> <meta name=”referrer” content=”origin” … Read more

Correct way to delete cookies server-side

Sending the same cookie value with ; expires appended will not destroy the cookie. Invalidate the cookie by setting an empty value and include an expires field as well: Set-Cookie: token=deleted; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT Note that you cannot force all browsers to delete a cookie. The client can configure the browser … Read more

What is httpinterceptor equivalent in angular2?

As @Günter pointed it out, there is no way to register interceptors. You need to extend the Http class and put your interception processing around HTTP calls First you could create a class that extends the Http: @Injectable() export class CustomHttp extends Http { constructor(backend: ConnectionBackend, defaultOptions: RequestOptions) { super(backend, defaultOptions); } request(url: string | … Read more

Ideal HTTP cache control headers for different types of resources

I would probably use these settings: Cache-Control: max-age=31556926 – Representations may be cached by any cache. The cached representation is to be considered fresh for 1 year: To mark a response as “never expires,” an origin server sends an Expires date approximately one year from the time the response is sent. HTTP/1.1 servers SHOULD NOT … Read more

How to catch exception correctly from http.request()?

Perhaps you can try adding this in your imports: import ‘rxjs/add/operator/catch’; You can also do: return this.http.request(request) .map(res => res.json()) .subscribe( data => console.log(data), err => console.log(err), () => console.log(‘yay’) ); Per comments: EXCEPTION: TypeError: Observable_1.Observable.throw is not a function Similarly, for that, you can use: import ‘rxjs/add/observable/throw’;

What are all the possible values for HTTP “Content-Type” header?

You can find every content type here: http://www.iana.org/assignments/media-types/media-types.xhtml The most common type are: Type application application/java-archive application/EDI-X12 application/EDIFACT application/javascript application/octet-stream application/ogg application/pdf application/xhtml+xml application/x-shockwave-flash application/json application/ld+json application/xml application/zip application/x-www-form-urlencoded Type audio audio/mpeg audio/x-ms-wma audio/vnd.rn-realaudio audio/x-wav Type image image/gif image/jpeg image/png image/tiff image/vnd.microsoft.icon image/x-icon image/vnd.djvu image/svg+xml Type multipart multipart/mixed multipart/alternative multipart/related (using by MHTML (HTML mail).) … Read more