On the integral $\int_0^\infty{\frac{\sin(\lambda x)\mathrm{d}x}{e^{2\pi x}-1}}$ In the book Asymptotics and Special Functions by Frank Olver, an integral formula of Legendre reads
$$\int_0^\infty{\frac{\sin(\lambda x)\mathrm{d}x}{e^{2\pi x}-1}}=\frac{1}{2(e^\lambda-1)}-\frac{1}{2\lambda}+\frac{1}{4}\text{ for }\lambda>0$$
Which is then used to prove an already-well-known integral
(by repeatedly differentiating with respect to $\lambda$ and setting $\lambda=0$ in the formula above):
$$\int_0^\infty{\frac{x^{2s-1}\mathrm{d}x}{e^{2\pi x}-1}}=(-1)^{s-1}\frac{B_{2s}}{4s}\text{ for }s>1$$
However, the author introduced, that the first formula can be obtained by straightforwardly integrating the function $\frac{e^{-i\lambda{z}}}{e^{2\pi{z}}-1}$, in which $\lambda>0$, around a rectangle with vertices at $0,K,K+i,i$, and indentations at $0$ and $i$. Then let $K\to\infty$ and the indentations shrink to zero.
I literally don't see how this works, if simply applied residue theorem, and how are the integrals combined. Could someone please show me more details about the process producing the first formula through such integration? Very appreciative.
Ps. I'm not a native English speaker, so I got confused with what he intrinsically meant by the term "indentations", the contour wasn't drawn so there's not an illustration ;)
EDIT.
HUUUGE gratitude to Mark Viola, I finally figured out the method.
The core is to only consider the imaginary part of the integral, which won't diverge.
(Added) Here's a modified version of my first approach following Mark's answer: (Equivalent)
Choose $0<\delta<\frac{1}{2}$
$$I=\int_\delta^K{\frac{e^{-i\lambda{x}}\mathrm{d}x}{e^{2\pi x}-1}}+\int_K^\delta{\frac{e^{-i\lambda(x+i)}\mathrm{d}x}{e^{2\pi(x+i)}-1}}+\int_K^{K+i}{\frac{e^{-i\lambda{x}}\mathrm{d}x}{e^{2\pi{x}}-1}}+e^\lambda\int_0^{\frac{3}{2}\pi}{\frac{e^{-i\lambda\delta{e^{i\theta}}}i\delta{e^{i\theta}}\mathrm{d}\theta}{e^{2\pi\delta{e^{i\theta}}}-1}}+\int_{\frac{\pi}{2}}^{2\pi}{\frac{e^{-i\lambda\delta{e^{i\theta}}}i\delta{e^{i\theta}}\mathrm{d}\theta}{e^{2\pi\delta{e^{i\theta}}}-1}}+\int_{\delta{i}}^{i-\delta{i}}{\frac{e^{-i\lambda x}\mathrm{d}x}{e^{2\pi x}-1}}=I_1+I_2+I_3+I_4+I_5+I_6$$
$I=i(e^\lambda+1)$ by residue theorem.
Taking the limit,
$$\Im(I_1+I_2)=\int_0^\infty{\Im(\frac{e^{-i\lambda{x}}}{e^{2\pi x}-1})\mathrm{d}x}(1-e^\lambda)=(e^\lambda-1)\int_0^\infty{\frac{\sin(\lambda x)\mathrm{d}x}{e^{2\pi x}-1}}$$
$$\left|I_3\right|\le\max_{0\le{x}\le1}{\left|\frac{e^{-i\lambda(ix+K)}}{e^{2\pi(ix+K)}-1}\right|}\to 0$$
$$\Im(I_4)=e^{\lambda}\int_0^{\frac{3}{2}\pi}{\Im(\frac{ie^\lambda}{2\pi}+O(\delta))\mathrm{d}\theta}=\frac{3e^\lambda}{4}$$
$$\Im(I_5)=\int_{\frac{\pi}{2}}^{2\pi}{\Im(\frac{ie^\lambda}{2\pi}+O(\delta))\mathrm{d}\theta}=\frac{3}{4}$$
$$\Im(I_6)=-\int_\delta^{1-\delta}{\Im(i\frac{e^{\lambda x}}{e^{2\pi ix}-1})\mathrm{d}x}=-\int_\delta^{1-\delta}{-\frac{e^{\lambda x}}{2}\mathrm{d}x}=_{\delta\to0}\frac{e^\lambda-1}{2\lambda}$$
Combine the results and we get the result.
 A: We begin by writing the integral around the prescribed contour $C$ as the sum of six integrals.  Proceeding, we obtain
$$\begin{align}
\int_{C}\frac{e^{-i\lambda z}}{e^{2\pi z}-1}\,dz&=\int_{\varepsilon}^K \frac{e^{-i\lambda x}}{e^{2\pi x}-1}\,dx-\int_{\varepsilon}^K \frac{e^{-i\lambda (x+i)}}{e^{2\pi x}-1}\,dx\\\\
&+\int_0^1 \frac{e^{-i\lambda (K+iy)}}{e^{2\pi (K+iy)}-1}\,i\,dy-\int_{\varepsilon}^{1-\varepsilon}\frac{e^{-i\lambda(iy)}}{e^{2\pi(iy)}-1}\,i\,dy\\\\
&-\int_0^{\pi/2}\frac{e^{-i\lambda(\varepsilon e^{i\phi})}}{e^{2\pi (\varepsilon e^{i\phi})}-1}\,i\varepsilon e^{i\phi}\,d\phi-\int_{3\pi/2}^{2\pi}\frac{e^{-i\lambda(i+\varepsilon e^{i\phi})}}{e^{2\pi \varepsilon e^{i\phi}}-1}\,i\varepsilon 
 e^{i\phi}\,d\phi\tag1
\end{align}$$

As $K\to \infty$, it is straightforward to show that the sum of the first three integral, $I_1$, $I_2$, and $I_3$, respectively, on the right-hand side of $(1)$ is given by
$$\lim_{K\to\infty}(I_1+I_2+I_3)=(1-e^{\lambda})\int_\varepsilon^\infty \frac{e^{-i\lambda x}}{e^{2\pi x}-1}\,dx\tag2$$
Taking the imaginary part of $(2)$ and letting $\varepsilon\to 0^+$, we find
$$\lim_{K\to\infty \\ \varepsilon \to 0^+}\text{Im}(I_1+I_2+I_3)=-(1-e^{\lambda})\int_\varepsilon^\infty \frac{\sin(\lambda x)}{e^{2\pi x}-1}\,dx\tag3$$

The fourth integral can be written as
$$\begin{align}
I_4&=-i\int_{\varepsilon}^{1-\varepsilon}\frac{e^{\lambda y}}{e^{2\pi(iy)}-1}\,dy\\\\
&=-\frac i2\int_{\varepsilon}^{1-\varepsilon} \frac{e^{\lambda y}((\cos(2\pi y)-1)-i\sin(2\pi y))}{1-\cos(2\pi y)}\,dy\\\\
&=\frac i2 \int_{\varepsilon}^{1-\varepsilon} e^{\lambda y}\,dy+\frac12 \int_{\varepsilon}^{1-\varepsilon} \frac{e^{\lambda y}\sin(2\pi y)}{1-\cos(2\pi y)}\,dy \tag4
\end{align}$$
Taking the imaginary part of $(4)$ and letting $\varepsilon\to  0^+$ reveals
$$\lim_{\varepsilon \to 0^+}\text{Im}(I_4)=\frac{e^{\lambda}-1}{2\lambda}\tag5$$

For the fifth and sixth integrals on the right-hand side of $(1)$ it easy easy to show that as $\varepsilon\to 0^+$ we have
$$\lim_{\varepsilon \to 0^+}\text{Im}(I_5+I_6)=-\frac12+\frac{1-e^{\lambda}}{4}\tag6$$

Combining $(3)$, $(5)$, and $(6)$ and aplying Cauchy'y Integral Theorem yields the result
$$\bbox[5px,border:2px solid #C0A000]{\int_0^\infty \frac{\sin(\lambda x)}{e^{2\pi x}-1}\,dx=\frac1{2(e^{\lambda}-1)}-\frac1{2\lambda}+\frac14}$$
as was to be shown!
A: A nice and straightforward solution was offered by @Mark Viola. I would like to propose another approach, which also uses complex integration, but in a bit another way.
$$I(\lambda)=\int_0^\infty\frac{\sin(\lambda x)}{e^{2\pi x}-1}dx=\int_0^\infty\sin(\lambda x)\Big(\sum_{k=1}^\infty e^{-2\pi kx}\Big)dx=\sum_{k=1}^\infty\frac{\lambda}{(2\pi k)^2+\lambda^2}=S_0$$
Let's also denote $S=\sum_{k=-\infty}^\infty\frac{1}{(2\pi k)^2+\lambda^2}$
It is easy to see that the desired sum $S_0=\frac{\lambda}{2}S-\frac{1}{2\lambda}$.
Now, we can evaluate $S$ in a standart way - integrating the function $f(z)=\frac{\pi\cot(\pi z)}{(2\pi z)^2+\lambda^2}$ in the complex plane along a big circle of radius $R\to\infty$.
On the one hand, the integrand declines as $\sim\frac{1}{z^2}$, therefore $\oint\to0$ at $R\to\infty$.
On the other hand, the integral is the sum of residues inside this circle:
$$\sum Res=0=S+Res_{z=\pm i\lambda/2\pi}\frac{\pi\cot(\pi z)}{(2\pi z)^2+\lambda^2}$$
$$\Rightarrow\,\, S=-\frac{2\pi^2}{(2\pi)^2}\frac{\cot\frac{i\lambda}{2}}{i\lambda}=\frac{1}{2\lambda}\frac{e^\lambda+1}{e^\lambda-1}$$
We get our integral (the sum $S_0$):
$$S_0=\frac{1}{4}\frac{e^\lambda+1}{e^\lambda-1}-\frac{1}{2\lambda}=\frac{1}{4}\frac{e^\lambda-1+2}{e^\lambda-1}-\frac{1}{2\lambda}=\frac{1}{2(e^{\lambda}-1)}-\frac{1}{2\lambda}+\frac{1}{4}$$
