~jpgleeson/spawsh

09365a78459e390323acba2eea450233fa9c55d8 — jpgleeson 1 year, 5 months ago cb811cf
Redirect Handling

Redirects should automatically redirect to the new location. There is an issue with redirects on gemini.circumlunar.space where going to the base without the trailing slash leads to an infinite 31 loop despite fetching at a 20 at some point. I need to figure out where I'm handling this wrong.
1 files changed, 19 insertions(+), 3 deletions(-)

M Program.cs
M Program.cs => Program.cs +19 -3
@@ 144,6 144,7 @@ namespace spawsh
                if (selectedLinkIndex == -1)
                {
                    Console.Write("url: ");
                    page = "";
                    newInput = Console.ReadLine();
                }
                else


@@ 199,7 200,7 @@ namespace spawsh

                responseData = ReadMessage(sslStream);

                //handleResponse(responseData);
                handleResponse(responseData);

            }
            client.Close();


@@ 226,7 227,7 @@ namespace spawsh

                if (firstSlashIndex == 0 || firstSlashIndex == 1)
                {
                    Console.WriteLine("Should be same server");
                    //Should be same server
                }
                else
                {


@@ 273,7 274,7 @@ namespace spawsh

                        if (!biggerArray[counter].Contains('.'))
                        {
                            Console.WriteLine("local link i think");
                            //These should be local links
                            biggerArray[counter] = server + "/" + biggerArray[counter];
                        }



@@ 340,6 341,21 @@ namespace spawsh
            {
                Console.WriteLine(responseBody);
            }
            else if (responseCode == "31")
            {
                string redirectAddress = responseHeader.Split(' ')[1];

                if (buildRequest(redirectAddress))
                {
                    Console.WriteLine("Redirect to {0}. Fetching.", redirectAddress);

                    LineBuffer = fetchPage();

                    linksInPage = buildLinkSet(LineBuffer);
                }

                selectedLinkIndex = -1;
            }
            else if (responseCode[0] == '3')
            {
                Console.WriteLine("Redirect to {0}", responseHeader.Split(' ')[1]);