You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2015/12/29 04:32:50 UTC
[3/5] mesos git commit: Use Path::extension to simplify libprocess
code.
Use Path::extension to simplify libprocess code.
Review: https://reviews.apache.org/r/41752
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0b119575
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0b119575
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0b119575
Branch: refs/heads/master
Commit: 0b1195753d3128817fa178969b2f242169eebfa8
Parents: 4ad002f
Author: Benjamin Mahler <be...@gmail.com>
Authored: Mon Dec 28 13:48:49 2015 -0800
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Dec 28 19:09:36 2015 -0800
----------------------------------------------------------------------
3rdparty/libprocess/src/process.cpp | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0b119575/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index cff635e..404206a 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -3267,13 +3267,10 @@ void ProcessBase::visit(const HttpEvent& event)
}
// Try and determine the Content-Type from an extension.
- string basename = Path(response.path).basename();
- size_t index = basename.find_last_of('.');
- if (index != string::npos) {
- string extension = basename.substr(index);
- if (assets[name].types.count(extension) > 0) {
- response.headers["Content-Type"] = assets[name].types[extension];
- }
+ Option<string> extension = Path(response.path).extension();
+
+ if (extension.isSome() && assets[name].types.count(extension.get()) > 0) {
+ response.headers["Content-Type"] = assets[name].types[extension.get()];
}
// TODO(benh): Use "text/plain" for assets that don't have an