Glenn9999 Posted March 21, 2010 Posted March 21, 2010 (I'm not sure where the best place would be to ask this, and this seems best) Are there any generally accepted rules for HTTP requests that are consistent with most sites? I ask because I've been trying to work (code-wise) on downloading a file pointed to by a valid fully qualified URL. Where I have it now is trying to handle "strange" URLs where valid files aren't necessarily specified. But I get stopped connection-wise if I try a main site link (like http://www.msfn.org/). So this got me wondering, and I'm not finding any good pages on it.What's the proper HTTP headers to be sending besides the obvious GET to download the file, in terms of what most sites will accept?
CoffeeFiend Posted March 21, 2010 Posted March 21, 2010 Usually it's pretty straightforward. For msfn it surely is. You can even try using plain old telnet:telnet 67.19.16.68 80GET /board/ HTTP/1.1Host: www.msfn.org(followed by enter twice)Works fine (you can see the markup fly by). Some sites require a few extras (e.g. "User-Agent: cloned-user-agent-string-here") but most of the time this is all you need. Obviously, some sites require authentication to download files.
Glenn9999 Posted March 21, 2010 Author Posted March 21, 2010 Usually it's pretty straightforward. For msfn it surely is.Thanks. It does seem so. The problem usually is to figure out what to expect. My problem that prompted this turned out to be that I was expecting a content length and that isn't valid for HTML. But still a good question, since I want what I'm working on to not be too "strange".
Glenn9999 Posted March 24, 2010 Author Posted March 24, 2010 Thanks. It does seem so. The problem usually is to figure out what to expect.Moreso again. I keep hitting this downloader code I have (I got it to resume now), and found a site that sends HTML *as* the HTTP headers. So I'm still wondering if there's some kind of universal standard (there has to be I would think or the browsers won't work right).Any ideas on this one?
RachelGomez Posted May 18, 2023 Posted May 18, 2023 When making HTTP requests to download files, here are some commonly used headers that most sites accept: User-Agent: Identifies the client or browser being used. Accept: Specifies the acceptable media types (MIME types) for the response. Referer: Indicates the URL of the referring webpage. Authorization: Used for authentication purposes. Cookie: Sends cookies from the client to the server. Content-Type: Specifies the type of content being sent in the request. Content-Length: Specifies the length of the request body in bytes. Keep in mind that specific websites may have additional requirements, so it's best to refer to their documentation or API reference for any additional headers or requirements. Regards, Rachel Gomez
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now