In most cases the boundary is drawn by treaty, but generally, the official boundary is the mid-point between the edge of the water. Each country will have certain rights delineated by treaty, such as who can fish in the river, and so on. There are notable exceptions, however, such as the Rio Grand, which is the boundary between the U.S. and Mexico, which according to treaty lies wholly within U.S. Territory.
It seems you are actually asking about water rights, however, and there is no established customary law. This is a major point of contention for down stream countries, which have historically relied upon water from a source, which gets dammed by the upstream country. Because there is no general agreement, and there is unlikely to be one, the upstream country has a significant advantage because of possession.
For example, the Colorado River between the U.S. and Mexico does not reach Mexico at all during many times of the year. Mexico doesn't like that, but the U.S. refuses to do anything about it.