• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

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
 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic