"Last-modified" date of a document through a web-browser - html

if you inspect a document (e.g. a pdf) on a web-browser, you can obtain a "last-modified date" of the document itself:
<embed id="plugin" type="application/x-google-chrome-pdf" src="http://mywebsite.org/mydocument.pdf" headers="Connection: Keep-Alive Content-Length: 144303 Content-Type: application/pdf Date: Thu, 22 Nov 2018 09:09:44 GMT; Keep-Alive: timeout=6, max=70 Last-Modified: Fri, 9 Nov 2018 09:43:03 GMT Server: Apache X-Content-Type-Option: nosniff " background-color="0xFF525659" top-toolbar-height="56" javascript="allow" full-frame="">
My question is: this "Last-Modified" date is referred to the time of the last change of the document as it stands before loading into the website, or to the time of load of the document into the website ?
Thank you,
best

From Mozilla:
The Last-Modified response HTTP header contains the date and time at
which the origin server believes the resource was last modified.

Related

How to make the download URL to return content-length in response?

This page (https://developers.google.com/drive/v2/web/manage-downloads) describes a method of obtaining download URL referred as Alternate method. This is what we use. We obtain this URL and then send GET request with this URL. The problem is that returned response does not have content-length and thus we cannot display a progress bar. Is there a way to force this URL to return content-length of the downloading content? We particularly interested in making this URL to return content-length because we pass the URL to different system which is specifically created for downloading and that system does not have logic calling GoogleDrive API. Here is example of the response header
HTTP/1.1 200 OK
X-GUploader-UploadID: AEnB2UobhZIKOBsST_-cDZt3BvIK2HSQ5ErTDPsA50BdhaAVrF9RD2Py-57pUoRnleNJnd_Xkg2_RoJClvYTzt0kZfaTSdQ61QB3tWXleX1RpefLObvFf2s
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
Access-Control-Allow-Headers: Accept, Accept-Language, Authorization, Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Content-Length, Content-MD5, Content-Range, Content-Type, Date, GData-Version, Host, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Origin, OriginToken, Pragma, Range, Slug, Transfer-Encoding, Want-Digest, X-ClientDetails, X-GData-Client, X-GData-Key, X-Goog-AuthUser, X-Goog-PageId, X-Goog-Encode-Response-If-Executable, X-Goog-Correlation-Id, X-Goog-Request-Info, X-Goog-Experiments, x-goog-iam-authority-selector, x-goog-iam-authorization-token, X-Goog-Spatula, X-Goog-Upload-Command, X-Goog-Upload-Content-Disposition, X-Goog-Upload-Content-Length, X-Goog-Upload-Content-Type, X-Goog-Upload-File-Name, X-Goog-Upload-Offset, X-Goog-Upload-Protocol, X-Goog-Visitor-Id, X-HTTP-Method-Override, X-JavaScript-User-Agent, X-Pan-Versionid, X-Origin, X-Referer, X-Upload-Content-Length, X-Upload-Content-Type, X-Use-HTTP-Status-Code-Override, X-Ios-Bundle-Identifier, X-Android-Package, X-YouTube-VVT, X-YouTube-Page-CL, X-YouTube-Page-Timestamp
Access-Control-Allow-Methods: GET,OPTIONS
Content-Type: application/zip
Content-Disposition: attachment;filename="bluemsx-code-1273.zip";filename*=UTF-8''bluemsx-code-1273.zip
Date: Tue, 04 Oct 2016 00:24:09 GMT
Expires: Tue, 04 Oct 2016 00:24:09 GMT
Cache-Control: private, max-age=0
X-Goog-Hash: crc32c=inH43w==
Transfer-Encoding: chunked
Server: UploadServer
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
If you check the documentation of download files in Google Drive API, there is no way to determine the content-length of a file.
So the alternative way, based on this SO question, is you need to use XMLHttpRequest in monitoring the progress of your download.
XMLHttpRequest provides the ability to listen to various events that can occur while the request is being processed. This includes periodic progress notifications, error notifications, and so forth.
Another way that I found is this tutorial that uses a special handler for monitoring progress called ProgressListener. Just check the tutorial link for more information and sample code.

Best and efficient way to parse both XML and HTML in C

folks!
I'm looking for the best and efficient way to parse server responds that content both HTML and XML stuff. The respond come from servers I need to poll each 5 minutes (it's about half a thousand of them in list currently, but it will double very soon). Respond stored in buffer as plane text (got from socket). So, I need to parse HTML part and in case of success (mandatory things found) I should then try to parse XML part and get statistics information to store in DB. The responses are like this:
HTTP/1.0 200 OK
Connection: close
Content-Length: 682
Content-Type: text/xml; charset=utf-8
Date: Sun, 09 Mar 2014 15:44:52 GMT
Last-Modified: Sun, 09 Mar 2014 15:44:52 GMT
Server: DrWebAV-DeskServer/REL-610-AV-6.02.0.201311040 Linux/x86_64 Lua/5.1.4 OpenSSL/1.0.0e
<?xml version="1.0" encoding="utf-8"?><avdesk-xml-api API='2.1.0' API_BUILD='20130709' branch='REL-610-AV' oper='get-server-info' rc='true' timestamp='20140309154452987' version='6.02.0.201311040'><server><id>00c1d140-d21d-b211-a828-b62919c4250d</id><platform>Linux 2.6.39-gentoo-r3 x86_64 (4 SMP Mon Oct 24 11:04:40 YEKT 2011)</platform><version>6.02.0.201311040</version><statistics from='20140301000000000' till='20140309235959999'><noviruses/><stations total='101'><online>5</online><deinstalled>21</deinstalled><blocked>0</blocked><expired>81</expired><offline>96</offline><activated>74</activated><unactivated>27</unactivated></stations></statistics></server></avdesk-xml-api>
And could be smth. like this
HTTP/1.0 401 Authorization Required
Cache-Control: post-check=0, pre-check=0
Connection: close
Content-Length: 421
Content-Type: text/html; charset=utf-8
Date: Sun, 09 Mar 2014 15:44:22 GMT
Expires: Date: Sat, 27 Nov 2004 10:18:15 GMT
Last-Modified: Date: Sat, 27 Nov 2004 10:18:15 GMT
Pragma: no-cahe
Server: DrWebAV-DeskServer/REL-610-AV-6.02.0.201311040 Linux/x86_64 Lua/5.1.4 OpenSSL/1.0.1
WWW-Authenticate: Basic realm="Dr.Web XML API area"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><TITLE>Unauthorized</TITLE><BODY><STRONG>Unauthorized</STRONG><P>The error "401 Unauthorized" occured while processing request you had sent.<P><BR><BR><I>Access denied or your browser does not support HTTP authentication!</I><BR><P><BR><BR><HR><P>Dr.Web ® AV-Desk Server REL-610-AV 6.02.0.201311040 Linux/x86_64 Lua/5.1.4 OpenSSL/1.0.1</BODY></HTML>
Concerning HTML part I'm basically interested in HTTP/1.0 STRING and Server: STRING stuff, and then need per-tag XML parsing, if authorization succeeded.
I have found, that libxml2 is suitable for parsing both HTML/XML stuff, but unable to find any real examples how to use it, just some major interface description. So, help needed.
Code examples for libxml2 are here
The mailing list is friendly, and the code is mature and good quality.
However, nothing in your example suggests you need to parse HTML. You need to parse (I think) HTTP to process the headers (and detect the 401 error from the HTTP response), then parse the XML content. Parsing HTTP headers to the level you require it is trivial (just strtok the response separating on line breaks and the first line has the answer you need). The body of the response starts after a double line break (I think your second example has a paste error). This reduces your task to simply processing HTTP headers and XML (no HTML parsing).

Unable to set cookies with Perl and Xampp

I'm using Xampp and Perl , when I try to set a cookie with CGI::Cookies or CGI::Session it prints the cookies data to the browser page instead of setting the cookie.
Example:
my $session = new CGI::Session();
my $cookie = CGI::Cookie->new(-name=>$session->name, -value=>$session->id);
print $session->header(-cookie=>$cookie, #_);
Result on the browser screen:
Set-Cookie: CGISESSID=cebc22d8046879efa9d0216eb8995d13; path=/
Date: Thu, 20 Feb 2014 04:34:22 GMT
Content-Type: text/html; charset=ISO-8859-1
It looks like that you had sent the header to the browser already.
After the standard header received by browser it handles every output as text.
Regards,

Service Stack Json Response Contains Extra Characters

I'm converting a Web Api project to service stack and in json responses I'm getting an extra line of text before and after the json content. I'm using fiddler to capture the response.
Edited for brevity, here is an example:
18d
[{"id": ... }]
0
What are these lines? I can't find any configuration option that would seem to correspond to keep this from happening.
Edit
I went back and started with the basic hello service stack example, and here's what I got for a response:
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/1.0
X-Powered-By: ServiceStack/3.943 Win32NT/.NET
Date: Thu, 18 Apr 2013 15:48:49 GMT
1b
{"Result":"Hello, JRandom"}
0
I'm assuming the extra response lines are the result of the Transfer-Encoding: chunked header.

PDF links getting stuck while loading in Chrome PDF Viewer

On a page of a website we're building http://ovsd.nutrislice.com/wellness/ , pdf download links ("Download the Issue") get stuck while loading in Chrome's PDF Viewer but work in all other browsers by triggering a download. Right click + "Save as" works in Chrome. I realize Chrome is the only browser with a built-in, default pdf viewer.
I figure we can instruct people to right click and then "save as", but I wanted to see if anyone can see a problem with either the html, or in the server response, which would cause chrome to fail like that.
Its not a traditional pass-thru file download sitting on a server somewhere. We use Heroku, and I'm currently storing the pdf's in the DB (I realize the downsides of this, but it was a simpler system than managing off-site files on S3 for now). I'm generating the response dynamically via a Django View, so I wonder if there's something i'm missing in the response headers or something.
Thanks!
Looks like a bad content-type:
Content-Type:('application/pdf', None)
Check your code where you are assigning a content-type to the response. Looks like you're sending a tuple instead of just application/pdf.
Like #dgel mentioned, your content type is incorrect:
$ curl -I http://ovsd.nutrislice.com/dbfiles/cms/resources/Vol5_Issue1_5_Dos_and_Donts_for_Supermarket_Survival.pdf
HTTP/1.1 200 OK
Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
Access-Control-Allow-Origin: *
Cache-Control: max-age=90000
Content-Type: ('application/pdf', None) # <- Incorrect
Date: Fri, 09 Nov 2012 19:25:06 GMT
Expires: Fri, 09 Nov 2012 23:20:28 GMT
Last-Modified: Thu, 08 Nov 2012 22:20:28 GMT
Server: gunicorn/0.14.6
Connection: keep-alive
Also it might be a good idea to add Content-Length header.