From nobody@FreeBSD.org  Tue May  8 07:27:15 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id DF94316A401
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  8 May 2007 07:27:15 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id D1BDD13C45A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  8 May 2007 07:27:15 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l487RFUq077838
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 8 May 2007 07:27:15 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l487MEYB075332;
	Tue, 8 May 2007 07:22:14 GMT
	(envelope-from nobody)
Message-Id: <200705080722.l487MEYB075332@www.freebsd.org>
Date: Tue, 8 May 2007 07:22:14 GMT
From: "Ryan C. Gordon"<icculus@icculus.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: libfetch doesn't support HTTP 307 "Temporary Redirect" results
X-Send-Pr-Version: www-3.0

>Number:         112515
>Category:       kern
>Synopsis:       [libfetch] [patch] libfetch doesn't support HTTP 307 "Temporary Redirect" results
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 08 07:30:03 GMT 2007
>Closed-Date:    Tue May 29 12:35:46 GMT 2007
>Last-Modified:  Tue May 29 12:35:46 GMT 2007
>Originator:     Ryan C. Gordon
>Release:        
>Organization:
>Environment:
>Description:

(I'm not actually running FreeBSD, I'm just using libfetch's source in a
different project. Thank you for writing it, it's really handy!)

libfetch has support for HTTP redirects, but doesn't have HTTP result 307
("Temporary Redirect") in the list of redirecting results, so it fails
these requests as an unknown error condition.



>How-To-Repeat:

Have libfetch attempt to download this URL:
   http://icculus.org/~icculus/dotplan/secondlife_screenie2.jpg   

The webserver will redirect you to the same path on a different server,
using a 307 result. You should end up here:

   http://offload1.icculus.org/~icculus/dotplan/secondlife_screenie2.jpg

..which will serve the content as expected...libfetch gives up when it
sees the 307 on the first server, though.



>Fix:

libfetch can handle this if 307 is added to its list of result codes. I have included a patch that makes the above URL work.



Patch attached with submission follows:

? libfetch-http-307.diff
Index: http.c
===================================================================
RCS file: /home/ncvs/src/lib/libfetch/http.c,v
retrieving revision 1.77
diff -u -r1.77 http.c
--- http.c	24 Aug 2005 12:28:05 -0000	1.77
+++ http.c	8 May 2007 07:12:02 -0000
@@ -92,6 +92,7 @@
 #define HTTP_MOVED_PERM		301
 #define HTTP_MOVED_TEMP		302
 #define HTTP_SEE_OTHER		303
+#define HTTP_TEMP_REDIRECT	307
 #define HTTP_NEED_AUTH		401
 #define HTTP_NEED_PROXY_AUTH	407
 #define HTTP_BAD_RANGE		416
@@ -99,6 +100,7 @@
 
 #define HTTP_REDIRECT(xyz) ((xyz) == HTTP_MOVED_PERM \
 			    || (xyz) == HTTP_MOVED_TEMP \
+			    || (xyz) == HTTP_TEMP_REDIRECT \
 			    || (xyz) == HTTP_SEE_OTHER)
 
 #define HTTP_ERROR(xyz) ((xyz) > 400 && (xyz) < 599)

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue May 8 08:18:45 UTC 2007 
Responsible-Changed-Why:  
To des for review (not necessarily for commit). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=112515 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/112515: commit references a PR
Date: Tue,  8 May 2007 19:28:12 +0000 (UTC)

 des         2007-05-08 19:28:03 UTC
 
   FreeBSD src repository
 
   Modified files:
     lib/libfetch         http.c 
   Log:
   Handle temporary redirects (HTTP status code 307)
   
   PR:             kern/112515
   Submitted by:   Ryan C. Gordon <icculus@icculus.org>
   MFC after:      3 weeks
   
   Revision  Changes    Path
   1.78      +2 -0      src/lib/libfetch/http.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Tue May 29 12:35:42 UTC 2007 
State-Changed-Why:  
MFCed 

http://www.freebsd.org/cgi/query-pr.cgi?pr=112515 
>Unformatted:
