How to compute the integral $\int_0^\infty\frac{x}{e^x+1}dx$ using the Residue theorem.

To use a rectangular contour, consider the integral

$$\oint_C dz \frac{z^2}{e^z+1}$$

where $C$ is the rectangular contour having vertices at $0$, $R$, $R+i 2 \pi$, and $i 2 \pi$, with a semicircular detour into the rectangle of radius $\epsilon$ at $z=i \pi$. The contour integral is then equal to

$$\int_0^R dx \frac{x^2}{e^x+1} + i \int_0^{2 \pi} dy \frac{(R+i y)^2}{e^{R+i y}+1} \\ + \int_R^0 dx \frac{(x+i 2 \pi)^2}{e^{x+i 2 \pi}+1} + i \int_{2 \pi}^{\pi+\epsilon} dy \frac{(i y)^2}{e^{i y}+1}\\ + i \epsilon \int_{\pi/2}^{-\pi/2} d\phi \, e^{i \phi} \frac{(i \pi+\epsilon e^{i \phi})^2}{e^{i \pi+\epsilon e^{i \phi}}+1}+i \int_{\pi-\epsilon}^0 dy \frac{(i y)^2}{e^{i y}+1}$$

We consider the limit as $R\to\infty$ and $\epsilon \to 0$. As $R\to\infty$, the second integral vanishes. As $\epsilon\to 0$, the fifth integral approaches

$$i \epsilon \int_{\pi/2}^{-\pi/2} d\phi \, e^{i \phi} \frac{-\pi^2}{-\epsilon e^{i \phi}}=-i \pi^3$$

By Cauchy's theorem, the contour integral is zero. We then have, expanding the first and third integrals and combining the fourth and sixth integrals into a Cauchy principal value:

$$-i 4 \pi \int_0^{\infty} dx \frac{x}{e^x+1} +4 \pi^2 \int_0^{\infty} \frac{dx}{e^x+1}\\ +i \,PV \int_0^{2 \pi} dy \frac{y^2}{e^{i y}+1}-i \pi^3=0$$

where $PV$ denotes the Cauchy principal value. Note that

$$PV \int_0^{2 \pi} dy \frac{y^2}{e^{i y}+1} = \frac12 \int_0^{2 \pi} dy \: y^2 -i \frac12 \, PV \int_0^{2 \pi} dy \frac{y^2 \sin{y}}{1+\cos{y}}$$

Equating imaginary parts, we see that

$$-4 \pi \int_0^{\infty} dx \frac{x}{e^x+1} + \frac12 \frac{(2 \pi)^3}{3} - \pi^3=0$$

or

$$\int_0^{\infty} dx \frac{x}{e^x+1} = \frac13 \pi^2-\frac14\pi^2 = \frac{\pi^2}{12}$$