How to detect if Console.In (stdin) has been redirected?

You can find out by p/invoking the Windows FileType() API function. Here’s a helper class: using System; using System.Runtime.InteropServices; public static class ConsoleEx { public static bool IsOutputRedirected { get { return FileType.Char != GetFileType(GetStdHandle(StdHandle.Stdout)); } } public static bool IsInputRedirected { get { return FileType.Char != GetFileType(GetStdHandle(StdHandle.Stdin)); } } public static bool IsErrorRedirected { … Read more

Python Requests library redirect new url

You are looking for the request history. The response.history attribute is a list of responses that led to the final URL, which can be found in response.url. response = requests.get(someurl) if response.history: print(“Request was redirected”) for resp in response.history: print(resp.status_code, resp.url) print(“Final destination:”) print(response.status_code, response.url) else: print(“Request was not redirected”) Demo: >>> import requests >>> … Read more

Authorization redirect on session expiration does not work on submitting a JSF form, page stays the same

Your concrete problem is most likely caused because your JSF command link/button is actually sending an ajax request which in turn expects a special XML response. If you’re sending a redirect as response to an ajax request, then it would just re-send the ajax request to that URL. This in turn fails without feedback because … Read more

Nodejs – Redirect url

The logic of determining a “wrong” url is specific to your application. It could be a simple file not found error or something else if you are doing a RESTful app. Once you’ve figured that out, sending a redirect is as simple as: response.writeHead(302, { ‘Location’: ‘your/404/path.html’ //add other headers here… }); response.end();

URL Fragment and 302 redirects

Update 2014-Jun-27: RFC 7231, Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content, has been published as a PROPOSED STANDARD. From the Changelog: The syntax of the Location header field has been changed to allow all URI references, including relative references and fragments, along with some clarifications as to when use of fragments would not be appropriate. … Read more

S3 Static Website Hosting Route All Paths to Index.html

It’s very easy to solve it without url hacks, with CloudFront help. Create S3 bucket, for example: react Create CloudFront distributions with these settings: Default Root Object: index.html Origin Domain Name: S3 bucket domain, for example: react.s3.amazonaws.com Go to Error Pages tab, click on Create Custom Error Response: HTTP Error Code: 403: Forbidden (404: Not … Read more