Is HTTP 404 an appropriate response for a PUT operation where some linked resource is not found? [closed]

There are a number of 4xx HTTP status codes. The most likely are either 404 or 409: 404 Not Found The server has not found anything matching the effective request URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, … Read more

CORS request with Preflight and redirect: disallowed. Workarounds?

The original standard does preclude redirect after a successful CORS preflight. Quoting ยง 7.1.5.3: This is the actual request. Apply the make a request steps and observe the request rules below while making the request. If the response has an HTTP status code of 301, 302, 303, 307, or 308 Apply the cache and network … Read more

Is it possible to use port 80 for both HTTP and web socket traffic?

YES, by using node.js. Express or connect for the HTTP file serving and socket.io for the WebSocket stuff. Example: var express = require(“express”); var app = express.createServer(); app.get(“https://stackoverflow.com/”, function(req, res){ res.redirect(“/index.html”); }); app.configure(function(){ app.use(express.static(__dirname + ‘/public’)); }); app.listen(80); var io = require(‘socket.io’); var socket = io.listen(app); socket.on(‘connection’, function(client){ client.on(‘message’, function(){…}); })

What could cause “connect ETIMEDOUT” error when the URL is working in browser?

When behind a proxy you need to make the following modifications (as explained in this answer): put the proxy host in the host parameter put the proxy port in the port parameter put the full destination URL in the path parameter : Which gives: var options = { host: ‘<PROXY_HOST>’, port: ‘<PROXY_PORT>’, path: ‘http://www.boardgamegeek.com/xmlapi/boardgame/1?stats=1’, method: … Read more

Adding http headers to window.location.href in Angular app

When you use $window.location.href the browser is making the HTTP request and not your JavaScript code. Therefore, you cannot add a custom header like Authorization with your token value. You could add a cookie via JavaScript and put your auth token there. The cookies will automatically be sent from the browser. However, you will want … Read more

Must websockets have heartbeats?

The RFC 6455, the current reference for the WebSocket protocol, defines some control frames to communicate state about the WebSocket: Close: 0x8 Ping: 0x9 Pong: 0xA Ping and Pong are used for heartbeat and allows you to check if the client is still responsive. See the quote below: A Ping frame may serve either as … Read more

Using http rest apis with angular 2

Well good answer provided by @langley but I would like to add some more points so posting as an answer. First of all for consuming Rest APIs we need the Http and HTTP_PROVIDERS modules to be imported. As we are talking about Http the very first step is obviously. <script src=”node_modules/angular2/bundles/http.dev.js”></script> But yes it is … Read more

http Post request with Typescript

Update 2020: Note that as of now, the global fetch is available on all modern browsers and covers 95% of all web users. If you need support for IE, read the original answer. MDN Doc | TypeScript Definition Where the function is available in the window or global contexts, looks like: fetch(input: RequestInfo, init?: RequestInit): … Read more