Also, probably exceptions should be handled here:

```
location = URI(res.headers['Location'])
```

as said, not tested ....