• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

need some help....

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ive done a server prog, that reads http req...
now i need i program taht can get req from the server prog. to read a txt file and to write a txt file please help:_
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's entertaining reading code in a language other than my own. Looks pretty much on the money tho.
What you're missing in your HandlelisteKlient is some code to read the request, figure out what is being asked for, and pump that back out.
HTTP GET requests are pretty easy to read. You can read headers with readln because they are terminated with newlines. Stop when you get a blank one.
The first header says "GET resource HTTPVersion". You can parse it on spaces and the middle word is the resource the client is asking for. You'll have to know how to relate that request to a path on your server.
You'll also want to send some response headers in front of your data. I send these two:
HTTP/1.1 200 Ok
Content-Type: text/plain
followed by a blank line, then start writing the requested file.
Lemme know if that made enough sense to go on. I can post parts of my Wiki server on my web site if that's not too much help - some folks really like to go it on their own.
[ May 05, 2004: Message edited by: Stan James ]
 
vegard ulv
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lol cheers somtin like this, but i still need it to write to a txt file on the server
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FWIW: Here's part of my Wiki server that deals reading GET and POST requests, including multipart file uploads. The MessageReader parses request headers. The Response object writes response headers.
http://www.surfscranton.com/files/HTTPServer.zip
 
reply
    Bookmark Topic Watch Topic
  • New Topic