Prove that $\int\limits_{-\infty}^{\infty} \frac{e^{-x}}{1+e^{-2\pi x}}\,dx=\frac1{2\sin\left(\frac{1}{2}\right)}$

For your question, you will have to consider a rectangular contour with vertices $\pm R$ and $\pm R+i$. I'm guessing the authors meant by "same technique" as in a rectangular contour situated in the upper half of the contour plane. Calling our integrand as $f(z)$

$$f(z)\equiv\frac {e^{-z}}{1+e^{-2\pi z}}$$

and parametrizing about all four sides of the contour gives us

$$\begin{multline}\oint\limits_{\mathrm C}dz\, f(z)=\int\limits_{-R}^{R}dz\, f(x)+i\int\limits_0^1dy\, f(R+yi)-\int\limits_{-R}^{R}dz\, f(z+i)-i\int\limits_0^1dy\, f(-R+yi)\end{multline}$$

When we take the limit as $R\to\infty$, it can be shown that the integrals of the vertical sides (i.e the second and fourth integrals) vanish. This can be justified using the estimation lemma. Both integrals have a length of $L=1$ while their upper-bound $M$ can be computed by using the fact that $|e^{-yi}|\leq 1$ and $|e^{\pm R}|=e^{\pm R}$.

$$\begin{align*}M_1 & =\left|\,\frac {e^{-R}e^{-yi}}{1+e^{-2\pi R}e^{-2\pi yi}}\,\right|=\frac {e^{-R}}{1+e^{-2\pi R}}\xrightarrow{R\,\to\,\infty}0\\M_2 & =\left|\,\frac {e^{R}e^{-yi}}{1+e^{2\pi R}e^{-2\pi yi}}\,\right|=\frac {e^{R}}{1+e^{2\pi R}}\xrightarrow{R\,\to\,\infty}0\end{align*}$$

Taking their product and calling their arcs $\Gamma_{1}$ and $\Gamma_{2}$ respectively

$$\begin{align*} & \left|\,\int\limits_{\Gamma_{1}}dz\,\frac {e^{-z}}{1+e^{-2\pi z}}\,\right|\leq M_1L=0\\ & \left|\,\int\limits_{\Gamma_{2}}dz\,\frac {e^{-z}}{1+e^{-2\pi z}}\,\right|\leq M_2L=0\end{align*}$$

As in, the arc integrals vanish as $R\to\infty$. Now, what's left is

$$\oint\limits_{\mathrm C}dz\, f(z)=(1-e^{-i})\int\limits_{-\infty}^{\infty}dx\, f(x)$$

The contour integral is also equal to the sum of its residues inside the contour multiplied by $2\pi i$. Fortunately, there is only one residue inside at $z=i/2$. Therefore

$$\operatorname*{Res}_{z\,=\, i/2}\frac {e^{-z}}{1+e^{-2\pi z}}=\lim\limits_{z\,\to\, i/2}\frac {(z-i/2)e^{-z}}{1+e^{-2\pi z}}=\frac {e^{-i/2}}{2\pi}$$

Hence the contour integral is

$$\oint\limits_{\mathrm C}dz\, f(z)=ie^{-i/2}$$

Putting everything together and isolating our integral $I$, we get

$$\int\limits_{-\infty}^{\infty}dx\,\frac {e^{-x}}{1+e^{-2\pi x}}=\frac {ie^{-i/2}}{1-e^{-i}}\color{blue}{=\frac 12\csc\left(\frac 12\right)}$$


Somewhat briefly:

  1. Take the rectangle with the upper corners at $-r+i$ and $r+i$. Then you get one residue at $z=i/2$ and the integral over $\gamma_3$ (orientation right to left) $$ -\int_{-r}^r\frac{e^{-x-i}}{1+e^{-2\pi(x+i)}}\,dx=-e^{-i}\int_{-r}^r\frac{e^{-x}}{1+e^{-2\pi x}}\,dx. $$ It gives as $r\to\infty$ the equation for the integral $I$ to be calculated $$ I+0-e^{-i}I+0=2\pi i\cdot\frac{e^{-i/2}}{2\pi}. $$ To finish is straightforward.
  2. "After a lot of calculations" may be simplified as e.g. for $\gamma_2$ $$ \left|\frac{e^{-r-i\theta}}{1+e^{-2\pi(r+i\theta)}}\right|= \frac{e^{-r}|e^{-i\theta}|}{|1+e^{-2\pi r}e^{-i2\pi\theta}|}\le \frac{e^{-r}\cdot 1}{1-|e^{-2\pi r}e^{-i2\pi\theta}|}=\frac{e^{-r}}{1-e^{-2\pi r}}\to 0,\quad r\to\infty. $$