소스 검색

slang.tcl: Get Location header case insensitively

The case apparently changed recently.
Will Storey 4 년 전
부모
커밋
8e6992f9a2
1개의 변경된 파일11개의 추가작업 그리고 1개의 파일을 삭제
  1. 11 1
      slang.tcl

+ 11 - 1
slang.tcl

@@ -186,7 +186,7 @@ proc ::ud::http_fetch {url page} {
 
 	# Follow redirects
 	if {[regexp -- {30[01237]} $ncode]} {
-		set new_url [dict get $meta Location]
+		set new_url [::ud::get_location_header $meta]
 		# We lose our page parameter apparently.
 		if {$page != -1 && $page != 1} {
 			append new_url &page=$page
@@ -210,6 +210,16 @@ proc ::ud::http_fetch {url page} {
 	return [::ud::parse_word_and_definitions $data]
 }
 
+proc ::ud::get_location_header {meta} {
+	dict for {k v} $meta {
+		set k [string tolower $k]
+		if {$k == "location"} {
+			return $v
+		}
+	}
+	error "Location header not found"
+}
+
 # parse a response from a file.
 # this is primarily for debugging purposes. we can pass this function
 # a stored response file to try to parse it.