How to evaluate $\int_{0}^{\infty} \frac{1}{x^{n}+1} d x?$ I first investigate the integral
$$\int_{0}^{\infty} \frac{1}{x^{6}+1} d x$$
using contour integration along the semicircle $\gamma=\gamma_{1} \cup \gamma_{2},$
$\textrm{ where }$ $$ \gamma_{1}(t)=t+i 0(-R \leq t \leq R)  \textrm{ and } \gamma_{2}(t)=R e^{i t}  (0<t<\pi) .$$
$$
\begin{aligned}
\int_{0}^{\infty} \frac{1}{x^{6}+1} d x &=\frac{1}{2} \int_{-\infty}^{\infty} \frac{d x}{x^{6}+1} \\
&=\frac{1}{2} \oint_{\gamma} \frac{d z}{z^{6}+1} \\
&=\frac{1}{2} \cdot 2 \pi i \sum_{k=0}^{2} \operatorname{Res}\left(\frac{1}{z^{6}+1} , z_k \right)
\end{aligned}
$$
with its simple poles at $ z_{k}=e^{\frac{(2 k+i) \pi}{6} i}$, where $k=0,1,2$.
Now lets evaluate the residues of $\frac{1}{z^{6}+1} $ at $ z_{k}$.
$$
\operatorname{Res}\left( \frac{1}{z^{6}+1} , z_{k}\right)=\frac{1}{6 z _k^{5}}=\frac{z_{k}}{6 z_{k}^{6}}=-\frac{z_{k}}{6}
$$
Putting the residues back yields
$$
\begin{aligned}
\int_{0}^{\infty} \frac{1}{x^{6}+1} d x &=\pi i\left(-\frac{1}{6}\left(z_{0}+z_{1}+z_{2}\right)\right) \\
&=-\frac{\pi i}{6}\left(e^{\frac{\pi}{6}}+e^{\frac{\pi}{2} i}+e^{\frac{5 \pi}{6} i}\right) \\
&=-\frac{\pi i}{6}\left(\frac{\sqrt{3}}{2}+\frac{1}{2} i+i-\frac{\sqrt{3}}{2}+\frac{1}{2} i\right) \\
&=\frac{\pi}{3}
\end{aligned}
$$

Similarly, we can deal with the integral in general
$$I_{2n}=\int_{0}^{\infty} \frac{1}{x^{2n}+1} d x$$
with the same contour $\gamma$ and $n $ simple poles whose residues are
$$
\operatorname{Res}\left( \frac{1}{z^{2n}+1} , z_{k}\right)=\frac{1}{2n z _k^{2n-1}}=\frac{z_{k}}{2n z_{k}^{2n}}=-\frac{z_{k}}{2n}
$$
$$
\begin{aligned}
\int_{0}^{\infty} \frac{1}{x^{2 n}+1} d x&=\pi i \sum_{k=0}^{n-1} \operatorname{Res}\left(\frac{1}{z^{2 n}+1}, z_k\right) \\
&=\pi i  \sum_{k=0}^{n-1}\left(-\frac{z _k}{2 n}\right)\\&=-\frac{\pi i}{2 n} \sum_{k=0}^{n-1} z_{k}\\&=-\frac{\pi i}{2 n} \sum_{k=0}^{n-1} e^{\frac{2 k+1}{2 n} \pi i}\\ &=-\frac{\pi i}{2 n} e^{\frac{\pi i}{2 n}} \cdot \frac{1-e^{\frac{\pi i}{n}(n)}}{1-e^{\frac{\pi i}{\pi}}}\\
&=-\frac{\pi i}{2 n} e^{\frac{\pi i}{2 n}} \cdot \frac{2}{1-e^{\frac{\pi}{n} i}}\\
&=-\frac{\pi i}{n} \frac{e^{\frac{\pi i}{2 n}}}{1-e^{\frac{\pi}{n} i}}\\&= -\frac{\pi i}{n} \cdot \frac{1}{e^{-\frac{\pi i}{2 n}}-e^{\frac{\pi i}{2 n}}}\\&= \frac{\pi}{2 n} \csc \frac{\pi}{2 n}
\end{aligned}
$$
However, I can’t use the same contour to deal with the odd one
$$\int_{0}^{\infty} \frac{1}{x^{2 n-1}+1} d x$$
as the simple pole $-1$ is on $\gamma_1$.
My Question: How can we evaluate the odd one?

Let $f(z) = \frac{1}{z^n + 1}$.
The trick is to pick a different contour. We choose the ray parametrised by $z(t) = e^{2 \pi i /n} t$ for $t \in [0, \infty)$.
We then have, after taking a bit of care with limits, $\int\limits_0^\infty f(t) dt - e^{2 \pi i / n} \int\limits_0^\infty f(t) dt = 2 \pi i Res(f(z), z = e^{\pi i / n}) = \frac{1}{ne^{\pi i (1 - 1/n))}}$.
Let $I = \int\limits_0^\infty f(t) dt$. Then we have $I (1 - e^{2 \pi i / n}) = \frac{2 \pi i}{n e^{\pi i (1 - 1/n)}}$.
Taking the modulus of both sides gives us $2I\sin(\pi / n) = \frac{2 \pi}{n}$. That is, $I = \frac{\pi}{n}\csc\frac{\pi}{n}$.
