Changeset 12794
- Timestamp:
- 2006-09-20T15:26:17+12:00 (18 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/cgiutils.cpp
r12579 r12794 81 81 break; 82 82 } 83 83 84 first++; 84 85 } 86 85 87 return first; 86 88 } … … 109 111 text_t tmp_name = md5data(filedata); 110 112 tmp_name = filename_cat(gsdlhome, "tmp", tmp_name); 113 111 114 char *tmp_name_c = tmp_name.getcstr(); 112 115 … … 133 136 // size has yet to be implemented 134 137 fu.size = filedata.size(); 138 135 139 fu.tmp_name = tmp_name; 136 140 fileuploads[argname] = fu; … … 155 159 if (findword(content_type_begin, content_type_end, "multipart/form-data") == content_type_end) { 156 160 // a simple post request 161 157 162 return raw_post_data; 158 163 … … 179 184 // first get the boundary from content-type 180 185 text_t::iterator boundary_begin = findword(content_type_begin, content_type_end, "boundary="); 181 if (boundary_begin+9 < content_type_end) boundary_begin += 9; 186 if (boundary_begin+9 < content_type_end) 187 { 188 // skip over "boundary=" part of string 189 boundary_begin += 9; 190 } 182 191 else { 183 192 // error 193 cerr << "Error: malformed boundary? '" << boundary_begin << "'" << endl; 184 194 return ""; 185 195 } 186 196 text_t boundary = substr(boundary_begin, getline(boundary_begin, content_type_end, false)); 187 197 int boundary_len = boundary.size(); 198 188 199 189 200 text_t argname, argdata, filename, filedata, filetype; … … 195 206 // get the next available line (including the trailing <CRLF> 196 207 text_t line = substr(data_here, getline(data_here, data_end, true)); 208 197 209 data_here += line.size(); 198 210 text_t::iterator line_begin = line.begin(); … … 245 257 else argdata += line; 246 258 } 259 247 260 } 248 261 … … 672 685 const cgiarginfo *info = argsinfo.getarginfo((*this_file).first); 673 686 if (info != NULL) { 687 674 688 if ((*info).fileupload && (file_exists((*this_file).second.tmp_name))) { 689 675 690 args.setargfile((*this_file).first, (*this_file).second); 676 691 } -
trunk/gsdl/src/recpt/cgiwrapper.cpp
r12514 r12794 24 24 *********************************************************************/ 25 25 26 #include <stdio.h> 27 #ifdef __WIN32__ 28 #include <fcntl.h> 29 #endif 30 26 31 #include "gsdlconf.h" 27 32 #include "cgiwrapper.h" … … 507 512 long content_length = (content_length_str ? atoi(content_length_str) : 0); 508 513 if (content_length > 0) { 514 #ifdef __WIN32__ 515 // On Windows it is important that standard input be read in binary 516 // mode, otherwise end of line "<CR><LF>" is turned into <LF> only 517 // which breaks the MIME standard (and our parsing code!) 518 519 int result = _setmode( _fileno( stdin ), _O_BINARY ); 520 if( result == -1 ) { 521 cerr << "Warning: Failed to set standard input to binary mode." << endl; 522 cerr << " Parsing of multi-part MIME will most likely fail" << endl; 523 } 524 #endif 525 509 526 long length = content_length; 510 527 unsigned char * buffer = new unsigned char[content_length]; 511 char c; 512 int i=0; 513 do { 514 cin.get(c); 515 if (cin.eof()) break; 516 buffer[i] = c; 517 ++i; 518 --length; 519 } while (length > 0); 520 528 529 int chars_read = fread(buffer,1,content_length,stdin); 530 531 if (chars_read != content_length) { 532 cerr << "Warning: mismatch between CONTENT_LENGTH and data read from standard in" << endl; 533 } 534 521 535 argstr.setcarr((char *)buffer, content_length); 536 522 537 text_t content_type; 523 538 char *content_type_str = getenv("CONTENT_TYPE"); -
trunk/gsdl/src/recpt/depositoraction.cpp
r12576 r12794 270 270 271 271 fileupload_t *fileupload = args.getargfile("di1userfileinfo"); 272 272 273 if (fileupload != NULL) { 274 273 275 if (!(*fileupload).tmp_name.empty() && file_exists((*fileupload).tmp_name)) { 274 276 // create the timestamp 275 277 time_t timestamp = time(NULL); 276 278 text_t timestamp_str(timestamp); 279 277 280 args["di1timestamp"] = timestamp_str; 278 281 … … 634 637 cerr << "Unable to copy " << tmpfile << " to " << filename << endl; 635 638 } 636 cerr << "*** filename = " << filename_textt << endl;637 639 638 640 //write the metadata file
Note:
See TracChangeset
for help on using the changeset viewer.