[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

backend referer patch



emacs-w3mのみなさま、はじめまして。
るびきちです。

emacs21で-nwでも色がつくようになって以来、
emacs-w3mに興味を持ちました。

さっそくパッチです。
backendでget/postするときにrefererも指定できるようにしました。



るびきち☆
http://voo.to/ruby/ ←Ruby大衆化計画(笑)

--- ../../compile/w3m-0.2.1-inu-1.5/backend.c	Thu Sep 27 21:30:08 2001
+++ backend.c	Thu Nov  8 05:16:58 2001
@@ -120,12 +120,12 @@
 }
 
 
-static void internal_get( char *url, int flag, FormList *request ){
+static void internal_get( char *url, int flag, FormList *request, char *referer ){
     Buffer *buf;
 
     backend_halfdump_str = Strnew_charp( "<pre>\n" );
     do_download = flag;
-    buf = loadGeneralFile( url, NULL, NO_REFERER, 0, request );
+    buf = loadGeneralFile( url, NULL, referer, 0, request );
     do_download = FALSE;
     if( buf != NULL && buf != NO_BUFFER ){
 	if( !strcasecmp( buf->type, "text/html" ) ){
@@ -162,17 +162,19 @@
 
 /* Command: get */
 static void get( TextList *argv ){
-    char *p, *url = NULL;
+    char *p, *url = NULL, *referer = NO_REFERER;
     int flag = FALSE;
 
     while(( p = popText( argv ) )){
 	if( !strcasecmp( p, "-download_only" ) )
 	    flag = TRUE;
+        else if( !strcasecmp( p, "-referer" ) )
+            referer = popText( argv );
 	else
 	    url = p;
     }
     if( url ){
-	internal_get( url, flag, NULL );
+	internal_get( url, flag, NULL, referer );
     }
 }
 
@@ -180,7 +182,7 @@
 /* Command: post */
 static void post( TextList *argv ){
     FormList *request;
-    char *p, *target = NULL, *charset = NULL,
+    char *p, *target = NULL, *charset = NULL, *referer = NO_REFERER,
 	*enctype = NULL, *body = NULL, *boundary = NULL, *url = NULL;
     int flag = FALSE, length = 0;
 
@@ -197,6 +199,8 @@
 	    body = popText( argv );
 	else if( !strcasecmp( p, "-boundary" ) )
 	    boundary = popText( argv );
+        else if( !strcasecmp( p, "-referer" ) )
+            referer = popText( argv );
 	else if( !strcasecmp( p, "-length" ) )
 	    length = atol( popText( argv ) );
 	else
@@ -207,7 +211,7 @@
 	request->body = body;
 	request->boundary = boundary;
 	request->length = ( length > 0 )? length : ( body ? strlen(body) : 0 );
-	internal_get( url, flag, request );
+	internal_get( url, flag, request, referer );
     }
 }