io.streams.limited: remove unlimit*
							parent
							
								
									57fb4267ab
								
							
						
					
					
						commit
						0bdc1514fd
					
				| 
						 | 
				
			
			@ -51,7 +51,6 @@ ERROR: no-boundary ;
 | 
			
		|||
SYMBOL: upload-limit
 | 
			
		||||
 | 
			
		||||
: read-multipart-data ( request -- mime-parts )
 | 
			
		||||
    unlimited-input
 | 
			
		||||
    upload-limit get limited-input 
 | 
			
		||||
    [ "content-type" header ]
 | 
			
		||||
    [ "content-length" header string>number limited-input ] bi
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -366,7 +366,7 @@ ERROR: not-a-jpeg-image ;
 | 
			
		|||
    [
 | 
			
		||||
        parse-marker { SOI } = [ not-a-jpeg-image ] unless
 | 
			
		||||
        parse-headers
 | 
			
		||||
        unlimited-input contents <loading-jpeg>
 | 
			
		||||
        contents <loading-jpeg>
 | 
			
		||||
    ] with-input-stream ;
 | 
			
		||||
 | 
			
		||||
PRIVATE>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,13 +27,6 @@ HELP: limit-stream
 | 
			
		|||
    }
 | 
			
		||||
} ;
 | 
			
		||||
 | 
			
		||||
HELP: unlimit-stream
 | 
			
		||||
{ $values
 | 
			
		||||
     { "stream" "an input stream" }
 | 
			
		||||
     { "stream'" "a stream" }
 | 
			
		||||
}
 | 
			
		||||
{ $description "Returns the underlying stream of a limited stream." } ;
 | 
			
		||||
 | 
			
		||||
HELP: limited-stream
 | 
			
		||||
{ $values
 | 
			
		||||
    { "value" "a limited-stream class" }
 | 
			
		||||
| 
						 | 
				
			
			@ -44,18 +37,11 @@ HELP: limited-input
 | 
			
		|||
{ $values { "limit" integer } }
 | 
			
		||||
{ $description "Wraps the current " { $link input-stream } " in a " { $link limited-stream } "." } ;
 | 
			
		||||
 | 
			
		||||
HELP: unlimited-input
 | 
			
		||||
{ $description "Returns the underlying stream of the limited-stream stored in " { $link input-stream } "." } ;
 | 
			
		||||
 | 
			
		||||
ARTICLE: "io.streams.limited" "Limited input streams"
 | 
			
		||||
"The " { $vocab-link "io.streams.limited" } " vocabulary wraps a stream to behave as if it had only a limited number of bytes, either throwing an error or returning " { $link f } " upon reaching the end. Limiting a non-seekable stream keeps a byte count and triggers the end-of-stream behavior when this byte count has been reached. However, limiting a seekable stream creates a window of bytes that supports seeking and re-reading of bytes in that window." $nl
 | 
			
		||||
"Wrap a stream in a limited stream:"
 | 
			
		||||
{ $subsections limited-stream }
 | 
			
		||||
"Wrap the current " { $link input-stream } " in a limited stream:"
 | 
			
		||||
{ $subsections limited-input }
 | 
			
		||||
"Unlimits a limited stream:"
 | 
			
		||||
{ $subsections unlimit-stream }
 | 
			
		||||
"Unlimits the current " { $link input-stream } ":"
 | 
			
		||||
{ $subsections unlimited-input } ;
 | 
			
		||||
{ $subsections limited-input } ;
 | 
			
		||||
 | 
			
		||||
ABOUT: "io.streams.limited"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,35 +54,6 @@ IN: io.streams.limited.tests
 | 
			
		|||
    4 over stream-read drop 10 swap stream-read
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
[ t ]
 | 
			
		||||
[
 | 
			
		||||
    "abc" <string-reader> 3 limit-stream unlimit-stream
 | 
			
		||||
    "abc" <string-reader> =
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
[ t ]
 | 
			
		||||
[
 | 
			
		||||
    "abc" <string-reader> 3 limit-stream unlimit-stream
 | 
			
		||||
    "abc" <string-reader> =
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
[ t ]
 | 
			
		||||
[
 | 
			
		||||
    [
 | 
			
		||||
        "resource:license.txt" utf8 <file-reader> &dispose
 | 
			
		||||
        3 limit-stream unlimit-stream
 | 
			
		||||
        "resource:license.txt" utf8 <file-reader> &dispose
 | 
			
		||||
        [ decoder? ] both?
 | 
			
		||||
    ] with-destructors
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[ "asdf" ] [
 | 
			
		||||
    "asdf" <string-reader> 2 <limited-stream> [
 | 
			
		||||
        unlimited-input contents
 | 
			
		||||
    ] with-input-stream
 | 
			
		||||
] unit-test
 | 
			
		||||
 | 
			
		||||
! pipes are duplex and not seekable
 | 
			
		||||
[ "as" ] [
 | 
			
		||||
    latin1 <pipe> [ 2 <limited-stream> ] change-in
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,12 +39,6 @@ M: object unlimit-stream ( stream -- stream' ) ;
 | 
			
		|||
: limited-input ( limit -- )
 | 
			
		||||
    [ input-stream ] dip '[ _ limit-stream ] change ;
 | 
			
		||||
 | 
			
		||||
: unlimited-input ( -- )
 | 
			
		||||
    input-stream [ unlimit-stream ] change ;
 | 
			
		||||
 | 
			
		||||
: with-unlimited-stream ( stream quot -- )
 | 
			
		||||
    [ clone unlimit-stream ] dip call ; inline
 | 
			
		||||
 | 
			
		||||
: with-limited-stream ( stream limit quot -- )
 | 
			
		||||
    [ limit-stream ] dip call ; inline
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue