Residue Integral 
Verify the integral with the aid of residues:
  $$\int^{\infty}_0\frac{x^2+1}{x^4+1}dx=\frac{\pi}{\sqrt 2}$$

I got: 
$f(z)=\frac{z^2+1}{z^4+1}$ and now I must find the residues for $f(z)$ and I got that the poles are: $e^{i\frac{\pi}{4}}$ and $e^{i\frac{3\pi}{4}}$. But I do not know how to finish. 

This answer, which uses residues, says that
$$
\frac{\pi}{m}\csc\left(\pi\frac{n+1}{m}\right)=\int_0^\infty\frac{x^n}{1+x^m}\,\mathrm{d}x
$$
Using $m=4$ and $n=0$ and $n=2$ yields
$$
\begin{align}
\int_0^\infty\frac{x^2+1}{z^4+1}\,\mathrm{d}x
&=\frac\pi4\csc\left(\frac14\pi\right)+\frac\pi4\csc\left(\frac34\pi\right)\\
&=\frac\pi4\sqrt2+\frac\pi4\sqrt2\\
&=\frac\pi{\sqrt2}
\end{align}
$$

The Long Way
Using the curve $\gamma$ which runs from $-R$ to $+R$ along the real axis then circles counter-clockwise from $+R$ to $-R$ through the upper half-plane, we get
$$
\begin{align}
\int_0^\infty\frac{x^2+1}{x^4+1}\,\mathrm{d}x
&=\frac12\int_{-\infty}^\infty\frac{x^2+1}{x^4+1}\,\mathrm{d}x\\
&=\frac12\int_\gamma\frac{z^2+1}{z^4+1}\,\mathrm{d}z\\
&=\frac{2\pi i}2\left(\frac{e^{2\pi i/4}+1}{4e^{3\pi i/4}}+\frac{e^{6\pi i/4}+1}{4e^{9\pi i/4}}\right)\\
&=\frac{2\pi i}2\left(\frac{e^{\pi i/4}+e^{-\pi i/4}}{4e^{2\pi i/4}}+\frac{e^{\pi i/4}+e^{-\pi i/4}}{4e^{2\pi i/4}}\right)\\
&=\pi\cos\left(\frac\pi4\right)\\
&=\frac\pi{\sqrt2}
\end{align}
$$
Since the residue at the singularities inside the contour $z=e^{\pi i/4}$ and $z=e^{3\pi i/4}$ is $\dfrac{z^2+1}{4z^3}$.
