perl - LWP::UserAgent getting 204 No Content response when POST in loop with multiple file contents -
i need post content multiple files, have read data multiple files , posting in loop. first file content post getting 200 ok response, second file content parsing second file content showing response 204 no content. below code. please me resolve this.
#! usr/bin/perl require lwp::useragent; use http::request::common; $ex_ok = 0; $ex_tempfail = -1; $url = 'http://jeffbeck.corp.apple.com:6080/parser/post'; $dir = $argv[0]; $i = 1; opendir dir, $dir or die "cannot open dir $dir: $!"; @filename = map{s/\.[^.]+$//;$_}grep {/\.eml$/} readdir dir; foreach $file (@filename){ print "$file \t $dir \n"; $filepath = "$dir/$file.eml"; print "$filepath \n"; #open file input , process that. open (myfile, $filepath) or die "couldn't open file $filepath : $!"; while(<myfile>) { #$mailcontent = $mailcontent . $_ ; @content = <myfile>; } print "###############################################\n"; print @content; print "\n###############################################\n"; close(myfile); #getting message id , replacing '@' '_' $messageid=''; foreach $mailcontent (@content){ if($mailcontent =~ m/message-id: \<(.*)\>/i) { $messageid = $1; } } $messageid =~ s/[@]/_/gi; print "my message id : $messageid \n"; print "my mail content : @content \n"; print "++++++++++++++++++++++++++++++++++++++\n"; #getting mailsize logged. $response; $mailsize = (length(@content)/1024); $browser = lwp::useragent->new; #post same url above messageid , mailcontent $response = $browser->post($url, [ 'messageid' => $messageid, 'mailcontent' => @content, ]); print "my response $response\n"; print $response->status_line; #fetch response , print output. if( $response->status_line =~ m{200 ok} ) { print "\tresponse success. code $ex_ok & message size $mailsize kb \n"; } else { print "\tresponse failure. code $ex_tempfail \n"; } } closedir dir;
Comments
Post a Comment