Based on this: https://math.stackexchange.com/a/4454826/595084
I want to find the integral $$I_1=\int^{\infty}_0\frac{\sin(x)}{e^x+1}\text{ d}x$$ In the method the answer uses, it converts this integral into $$I(n)=\int^{\infty}_0\frac{\sinh(nx)}{e^x+1}\text{ d}x$$ and solves for $-iI(i)$. In other words, it converted the integral into $$I_2=\int^{\infty}_0\frac{-i\sinh(ix)}{e^x+1}\text{ d}x$$ In the process of finding $I(n)$, we perform the substitutions detailed in the aforementioned answer and arrive at two integrals, namely $$A=\int^{\infty}_0\frac{x^{-n}}{x+1}\text{ d}x$$ $$B=\int^{\infty}_1x^{-n-1}\text{ d}x$$ Solving these integrals however give us some restrictions. For instance, when we solve for $B$, the upper bound forces us to place the restriction that $\Re(n)>0$ due to the fact that $\frac{1}{\infty^{bi}}$ is undefined for any constant $b$ for $b\in\mathbb{R}$.
Not only that, to solve for $A$, I set up a branch cut (since $n$ is not an integer, it can be classified as a root, and thus through testing $0$ is a branch point. We can set up starting from there in any direction) along the positive real axis and used a keyhole contour (I think I could have used a rectangular contour, but that requires 5 integrals while the keyhole has 4, so I picked the latter).
In the process of solving the integral for the outer part of the keyhole contour, I was forced to place the restriction that $0<\Re(n)<1$ to have it vanish.
In the end, the result for $I(n)$ was $$\frac{\pi}{2}\csc(\pi n)−\frac{1}{2n}$$ Plugging in $n=i$ and multiplying by $-i$ does indeed give us the correct answer. However, this is not supposed to happen.
Clearly, $\Re(i)=0$, which violates the fact that $\Re(n)>0$. As a matter of fact, if we place the substitution $n=i$ in prematurely, say into $B$, the integral even fails to converge! The upper bound basically means that we rotate around the origin an infinite amount of times. I don't even think the integral converges in a Lebesgue sense, much less Riemann.
So why is it that despite clearly violating the restrictions that exist, plugging in $n=i$ for $I(n)$ works for calculating $I_1$?