Deleted Added
full compact
http.subr (253333) http.subr (255818)
1if [ ! "$_MEDIA_HTTP_SUBR" ]; then _MEDIA_HTTP_SUBR=1
2#
3# Copyright (c) 2012-2013 Devin Teske
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 10 unchanged lines hidden (view full) ---

19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
1if [ ! "$_MEDIA_HTTP_SUBR" ]; then _MEDIA_HTTP_SUBR=1
2#
3# Copyright (c) 2012-2013 Devin Teske
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 10 unchanged lines hidden (view full) ---

19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# $FreeBSD: head/usr.sbin/bsdconfig/share/media/http.subr 253333 2013-07-14 03:08:52Z dteske $
27# $FreeBSD: head/usr.sbin/bsdconfig/share/media/http.subr 255818 2013-09-23 16:47:52Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." media/http.subr
34f_include $BSDCFG_SHARE/device.subr
35f_include $BSDCFG_SHARE/dialog.subr

--- 36 unchanged lines hidden (view full) ---

72#
73f_dialog_menu_media_http()
74{
75 f_dialog_title "$msg_please_select_a_freebsd_http_distribution_site"
76 local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
77 f_dialog_title_restore
78 local prompt="$msg_please_select_the_site_closest_to_you_or_other"
79 local menu_list="
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." media/http.subr
34f_include $BSDCFG_SHARE/device.subr
35f_include $BSDCFG_SHARE/dialog.subr

--- 36 unchanged lines hidden (view full) ---

72#
73f_dialog_menu_media_http()
74{
75 f_dialog_title "$msg_please_select_a_freebsd_http_distribution_site"
76 local title="$DIALOG_TITLE" btitle="$DIALOG_BACKTITLE"
77 f_dialog_title_restore
78 local prompt="$msg_please_select_the_site_closest_to_you_or_other"
79 local menu_list="
80 'URL' '$msg_specify_some_other_http_site'
80 '$msg_main_site' 'ftp.freebsd.org'
81 'URL' '$msg_specify_some_other_http_site'
81 " # END-QUOTE
82 local hline="$msg_select_a_site_thats_close"
83
84 local height width rows
85 eval f_dialog_menu_size height width rows \
86 \"\$title\" \
87 \"\$btitle\" \
88 \"\$prompt\" \

--- 296 unchanged lines hidden (view full) ---

385 fi
386 [ "$connect_only" ] && return $SUCCESS
387
388 local http_path
389 f_getvar $VAR_HTTP_PATH http_path
390 f_show_info "$msg_checking_access_to" "$http_path"
391
392 local rx
82 " # END-QUOTE
83 local hline="$msg_select_a_site_thats_close"
84
85 local height width rows
86 eval f_dialog_menu_size height width rows \
87 \"\$title\" \
88 \"\$btitle\" \
89 \"\$prompt\" \

--- 296 unchanged lines hidden (view full) ---

386 fi
387 [ "$connect_only" ] && return $SUCCESS
388
389 local http_path
390 f_getvar $VAR_HTTP_PATH http_path
391 f_show_info "$msg_checking_access_to" "$http_path"
392
393 local rx
394 case "$http_path" in
395 http://*|/*) : valid request ;;
396 *) http_path="/$http_path" # full URI requests only
397 esac
393 if ! rx=$(
398 if ! rx=$(
394 printf "GET /%s/ HTTP/1.0\r\n\r\n" "${http_path%/}" |
399 printf "GET %s/ HTTP/1.0\r\n\r\n" "${http_path%/}" |
395 nc -n "$host" "$http_port"
396 ); then
397 f_show_msg "$msg_couldnt_connect_to_server http://%s:%s/" \
398 "$http_host" "$http_port"
399 unset $VAR_HTTP_HOST
400 return $FAILURE
401 fi
402

--- 175 unchanged lines hidden (view full) ---

578 if [ ! "$connected" ]; then
579 f_show_msg "$msg_couldnt_connect_to_server http://%s:%s/" \
580 "$http_host" "$http_port"
581 return $FAILURE
582 fi
583
584 local http_path
585 f_getvar $VAR_HTTP_PATH%/ http_path
400 nc -n "$host" "$http_port"
401 ); then
402 f_show_msg "$msg_couldnt_connect_to_server http://%s:%s/" \
403 "$http_host" "$http_port"
404 unset $VAR_HTTP_HOST
405 return $FAILURE
406 fi
407

--- 175 unchanged lines hidden (view full) ---

583 if [ ! "$connected" ]; then
584 f_show_msg "$msg_couldnt_connect_to_server http://%s:%s/" \
585 "$http_host" "$http_port"
586 return $FAILURE
587 fi
588
589 local http_path
590 f_getvar $VAR_HTTP_PATH%/ http_path
586 local url="/$http_path/$file" rx
591 case "$http_path" in
592 http://*|/*) : valid request ;;
593 *) http_path="/$http_path" # full URI requests only
594 esac
587
595
596 local url="$http_path/$file" rx
588 f_dprintf "sending http request for: %s" "$url"
589 printf "GET %s HTTP/1.0\r\n\r\n" "$url" | nc -n "$host" "$http_port" |
590 (
591 #
592 # scan the headers of the response
593 # this is extremely quick'n dirty
594 #
595

--- 53 unchanged lines hidden ---
597 f_dprintf "sending http request for: %s" "$url"
598 printf "GET %s HTTP/1.0\r\n\r\n" "$url" | nc -n "$host" "$http_port" |
599 (
600 #
601 # scan the headers of the response
602 # this is extremely quick'n dirty
603 #
604

--- 53 unchanged lines hidden ---