Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS2 / HTTP_10_Request.cpp
blob66a40a8b0f0d719e54f4a5f192be7f43caa0bc11
1 #include "JAWS/JAWS.h"
2 #include "HTTP_10_Request.h"
3 #include "ace/OS_NS_pwd.h"
6 static int dummy;
8 JAWS_HTTP_10_Request::JAWS_HTTP_10_Request ()
9 : path_ (0)
13 JAWS_HTTP_10_Request::~JAWS_HTTP_10_Request ()
15 ACE_OS::free (this->path_);
16 this->path_ = 0;
19 const char *
20 JAWS_HTTP_10_Request::method () const
22 return this->request_line ()->method_str ();
25 const char *
26 JAWS_HTTP_10_Request::uri () const
28 return this->request_line ()->url ();
31 const char *
32 JAWS_HTTP_10_Request::version () const
34 return this->request_line ()->version ();
37 int
38 JAWS_HTTP_10_Request::type () const
40 return this->request_line ()->method ();
43 const char *
44 JAWS_HTTP_10_Request::path () const
46 if (this->path_ == 0)
48 JAWS_HTTP_10_Request *mutable_this = (JAWS_HTTP_10_Request *)this;
49 mutable_this->path (this->uri ());
51 return this->path_;
54 void
55 JAWS_HTTP_10_Request::set_status (int s)
57 HTTP_Request::set_status (s);
60 void
61 JAWS_HTTP_10_Request::path (const char *uri_string)
63 char const *file_name = uri_string;
64 char buf[MAXPATHLEN + 1];
65 buf[0] = '\0';
67 if (file_name == 0) return;
69 if (*file_name == '/')
71 file_name++;
72 if (*file_name == '~')
74 char *ptr = buf;
76 while (*++file_name && *file_name != '/')
77 *ptr++ = *file_name;
79 *ptr = '\0';
81 if (ptr == buf)
82 ACE_OS::strcpy (buf, ACE_OS::getenv ("HOME"));
83 else
85 #if !defined (ACE_WIN32) && !defined (VXWORKS)
86 char pw_buf[BUFSIZ];
87 struct passwd pw_struct;
88 if (ACE_OS::getpwnam_r (buf, &pw_struct, pw_buf, sizeof (pw_buf))
89 == 0)
90 return;
91 ACE_OS::strcpy (buf, pw_struct.pw_dir);
92 #endif /* NOT ACE_WIN32 AND NOT VXWORKS */
95 ACE_OS::strcat (buf, "/");
96 #if 0
97 ACE_OS::strcat (buf, HTTP_Config::instance ()->user_dir ());
98 #else
99 ACE_OS::strcat (buf, ".www-docs");
100 #endif
101 ACE_OS::strcat (buf, file_name);
103 else
105 // With a starting '/' but no '~'
106 #if 0
107 ACE_OS::strcat (buf, HTTP_Config::instance ()->document_root ());
108 #else
109 ACE_OS::strcat (buf, ".");
110 #endif
111 ACE_OS::strcat (buf, file_name - 1);
115 if (*buf != '\0')
116 this->path_ = ACE_OS::strdup (buf);