Slide 1

Slide 1 text

PINCH Some crazy HTTP ZIP Magic

Slide 2

Slide 2 text

@peterhellberg

Slide 3

Slide 3 text

I’m a Senior Systems Architect at Athega (where I build stuff in Ruby) ⃔ I’m also the owner o Code7 Interactive (where I build stuff in Ruby) ⃕

Slide 4

Slide 4 text

Retrieve a ile rom inside a ZIP ile, over the network! Pretty sweet, eh?

Slide 5

Slide 5 text

require 'pinch' url = 'http://peterhellberg.github.com/pinch/test.zip' data = Pinch.get(url, 'data.json') # Do something with the data How?

Slide 6

Slide 6 text

Now, let’s go back in⏰

Slide 7

Slide 7 text

’89 APPNOTE.TXT http://PKWARE.com/documents/casestudies/APPNOTE.TXT

Slide 8

Slide 8 text

FILE ENTRY 1 FILE ENTRY 2 CENTRAL DIRECTORY END OF CENTRAL DIRECTORY Signature 0x06054b50 ZIP File Format

Slide 9

Slide 9 text

Pinch does NOT understand the ZIP File Format

Slide 10

Slide 10 text

HTTP/1.1 14.16 Content-Range ❤ || ☠

Slide 11

Slide 11 text

1 HEAD Total ile size 2 GET Last 4096 bytes (End of Central Directory) 3 GET Central Directory start → Central Directory start + size 4 GET File offset → File offset + (compressed) size HTTP Requests

Slide 12

Slide 12 text

String#unpack Zlib::In late Array#pack

Slide 13

Slide 13 text

gem install pinch

Slide 14

Slide 14 text

github.com/peterhellberg/pinch

Slide 15

Slide 15 text

@peterhellberg peterhellberg.info git.io/peterhellberg