Esempio n. 1
0
            /// <exception cref="Javax.Servlet.ServletException"/>
            /// <exception cref="System.IO.IOException"/>
            protected override void DoGet(HttpServletRequest request, HttpServletResponse response
                                          )
            {
                PrintWriter @out = response.GetWriter();
                IDictionary <string, string[]> @params = request.GetParameterMap();
                ICollection <string>           keys    = new TreeSet <string>(@params.Keys);

                foreach (string key in keys)
                {
                    @out.Write(key);
                    @out.Write(':');
                    string[] values = @params[key];
                    if (values.Length > 0)
                    {
                        @out.Write(values[0]);
                        for (int i = 1; i < values.Length; ++i)
                        {
                            @out.Write(',');
                            @out.Write(values[i]);
                        }
                    }
                    @out.Write('\n');
                }
                @out.Close();
            }
Esempio n. 2
0
            /// <param name="request">the object from which this servlet reads the url contents</param>
            /// <param name="response">the object into which this servlet writes the url contents
            ///     </param>
            /// <exception cref="System.IO.IOException">if the request is bad</exception>
            public GetImageParams(HttpServletRequest request, HttpServletResponse response)
            {
                IDictionary <string, string[]> pmap = request.GetParameterMap();

                isGetImage = isGetEdit = fetchLatest = false;
                foreach (KeyValuePair <string, string[]> entry in pmap)
                {
                    string   key = entry.Key;
                    string[] val = entry.Value;
                    if (key.Equals("getimage"))
                    {
                        isGetImage = true;
                        try
                        {
                            txId = ServletUtil.ParseLongParam(request, TxidParam);
                            string imageType = ServletUtil.GetParameter(request, ImageFileType);
                            nnf = imageType == null ? NNStorage.NameNodeFile.Image : NNStorage.NameNodeFile.ValueOf
                                      (imageType);
                        }
                        catch (FormatException nfe)
                        {
                            if (request.GetParameter(TxidParam).Equals(LatestFsimageValue))
                            {
                                fetchLatest = true;
                            }
                            else
                            {
                                throw;
                            }
                        }
                    }
                    else
                    {
                        if (key.Equals("getedit"))
                        {
                            isGetEdit = true;
                            startTxId = ServletUtil.ParseLongParam(request, StartTxidParam);
                            endTxId   = ServletUtil.ParseLongParam(request, EndTxidParam);
                        }
                        else
                        {
                            if (key.Equals(StorageinfoParam))
                            {
                                storageInfoString = val[0];
                            }
                        }
                    }
                }
                int numGets = (isGetImage ? 1 : 0) + (isGetEdit ? 1 : 0);

                if ((numGets > 1) || (numGets == 0))
                {
                    throw new IOException("Illegal parameters to TransferFsImage");
                }
            }
Esempio n. 3
0
        /// <summary>Handle fsck request</summary>
        /// <exception cref="System.IO.IOException"/>
        protected override void DoGet(HttpServletRequest request, HttpServletResponse response
                                      )
        {
            IDictionary <string, string[]> pmap = request.GetParameterMap();
            PrintWriter @out          = response.GetWriter();
            IPAddress   remoteAddress = Sharpen.Extensions.GetAddressByName(request.GetRemoteAddr
                                                                                ());
            ServletContext       context = GetServletContext();
            Configuration        conf    = NameNodeHttpServer.GetConfFromContext(context);
            UserGroupInformation ugi     = GetUGI(request, conf);

            try
            {
                ugi.DoAs(new _PrivilegedExceptionAction_58(context, conf, pmap, @out, remoteAddress
                                                           ));
            }
            catch (Exception e)
            {
                response.SendError(400, e.Message);
            }
        }
Esempio n. 4
0
        private static HttpServletRequest ToLowerCase(HttpServletRequest request)
        {
            IDictionary <string, string[]> original = (IDictionary <string, string[]>)request.GetParameterMap
                                                          ();

            if (!ParamFilter.ContainsUpperCase(original.Keys))
            {
                return(request);
            }
            IDictionary <string, IList <string> > m = new Dictionary <string, IList <string> >();

            foreach (KeyValuePair <string, string[]> entry in original)
            {
                string         key     = StringUtils.ToLowerCase(entry.Key);
                IList <string> strings = m[key];
                if (strings == null)
                {
                    strings = new AList <string>();
                    m[key]  = strings;
                }
                foreach (string v in entry.Value)
                {
                    strings.AddItem(v);
                }
            }
            return(new _HttpServletRequestWrapper_111(m, request));
        }