So upset about this. I am trying to do a very simple thing here.
I try to insert a string at the head of a html file in an Apache module, the code is simple.
apr_bucket* txt_esc(apr_bucket_alloc_t* alloc )
{
return apr_bucket_transient_create("ggggggggggggggg", 15, alloc) ;
}
apr_status_t add_string(ap_filter_t *f, apr_bucket_brigade *pbbIn)
{
APR_BRIGADE_INSERT_HEAD(pbbIn, txt_esc(f->r->connection->bucket_alloc));
return ap_pass_brigade(f->next, pbbIn);
}
The problem is that I can insert the string at the head, but meantime, the content of the same size of the string at the end of the html file will be truncated.
Anybody knows why this happens? This Apache server is running as a proxy.
Related
I am using the graphaware php client for neo4j.
When running a query with a "large" parameter object (about 200 lines in pretty print, field values are 30 characters max), it freezes.
The $queryparams object looks like
{
"data": {
"someproperty": 30000,
"anotherproperty": "stringentry",
<about 200 more like this here, partially nested>
}
}
where
everything is inside the data wrapper
most of the 200 entries are garbage that the query never uses
The line
$queryresult = $client->run($query, $queryparams);
becomes long-running and gets time-outed by nginx. I tried
try
{
$queryresult = $client->run($query, $queryparams);
} catch (Neo4jException $e)
{
return "error";
}
to no avail.
Running the same query with the same parameters in the neo4j browser, I get my results instantaneously.
Any ideas about what is causing the problem? Is it graphaware?
EDIT: I posted too fast, but this was unexpected to me: there is a field "0": ... somewhere in the $queryparams inside the garbage I mentioned. That is what causing the problem. Is this intended behaviour?
Im new here and have a Problem with PDFBox.
Im trying to print a single PDF Document, but it doesnt work so far.
I found some examples in the internet, but dont get it run, so I hope someone here has an idea, where my mystake is.
The Code I have so far is:
File datei = new File("D:\\161413070_00-76-150-1803_FIP_170109.pdf");
if(datei.exists())
{
try(PDDocument doc = PDDocument.load(datei)) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPageable(new PDFPageable(doc));
if(job.printDialog())
{
job.print();
}
doc.close();
}catch(InvalidPasswordException ivpwe)
{
Logger.getLogger(WinScanJ.class.getName()).log(Level.SEVERE, null, ivpwe);
}
catch(IOException | PrinterException ioe)
{
Logger.getLogger(WinScanJ.class.getName()).log(Level.SEVERE, null, ioe);
}
}
The program is opening the print dialog which is fine and it seems to send out a print job. I can see a Print Job in the print queue in windows for about a second, but the printer isnt printing something.
I have a network printer here and it works fine.
I guess my program is sending an empty print advice, but dont know why. The specified PDF Document exists and isn`t empty.
Does anybody have an idea what the problem could be?
Thanks in advice
TDO
I think the issue is with the UrlMapping file or some configuration file that I don't know about but I didn't see it addressed in this site so I'm posting for help.
I have a UrlMappings.groovy with:
"/lookupMap/$fromVal/$toVal/xml/$id**" (controller:"lookup, action:"returnMapXml", formats=['xml'], method:"GET")
and the controller is:
def returnMapXml = {
if (params.id) {
print params.id + "\n";
try {
def result = getLookup.result(params.fromVal, params.toVal, params.id)
render ...yadda yadda
}
}
}
This is a REST service. My problem happens when someone enters an ID value with either a pound sign (#) or question mark (?), the value is truncated at that character. For example the output of ID (per the print line in the code) for this: localhost:8080/productdefinition/lookupMap/Denver/Toronto/carton OR container OR box? OR bag would be carton OR container OR box It removes the ? and everything after it. This happens somewhere either before it gets to the UrlMappings file or when that directs the call to the controller. Either way, how can I stop this and where, which file do I fix this in? I don't have access to the server so I can't alter any URL encodings; this has to be a code update. Any help/direction would be appreciated.
I'm new to scala and spray and I'm having a very simple problem. I want my rest service to return unescaped strings when I return a string from a rest call, it stead i'm getting a compacted string with escapes in it. Here is my code:
Rest Service:
....
get {
respondWithMediaType(MediaTypes.`text/plain`) {
complete {
s"""
hey joe this is
"me"
bill"""
}
}
}
When I call the my service I get:
"\nhey joe this is\n\"me\"\n\bill"
But if I do a println() I see what I would expect. Please help.
I solved my own problem, it was the JSON support trait that was automatically marshalling the object
This trait Json4sSupport automatally marshal your objects as JSON hence the wrapping and compact print etc.
import spray.httpx.Json4sSupport
If you remove it you should be getting the unescaped results.
hope it helps anyone else out there.
We had the same problem using Jackson; we worked around the issue by creating an http response object instead, like so…
respondWithMediaType(`text/html`) {
complete {
new HttpResponse(StatusCodes.OK, HttpEntity(
"""
|<!DOCTYPE html>
|<html>
|<head>
|<title>Download app</title>
|</head>
|<body>
|<h2>
|Click here<br>
|</h2>
|</body>
|</html>
""".stripMargin
))
}
}
I want to parse a random website, modify the content so that every word is a link (for a dictionary tooltip) and then display the website in an iframe.
I'm not looking for a complete solution, but for a hint or a possible strategy. The linking is my problem, parsing the website and displaying it in an iframe is quite simple. So basically I have a String with all the html content. I'm not even sure if it's better to do it serverside or after the page is loaded with JS.
I'm working with Ruby on Rails, jQuery, jRails.
Note: The content of the href tag depends on the word.
Clarification:
I tried a regexp and it already kind of works:
#site.gsub!(/[A-Za-z]+(?:['-][A-Za-z]+)?|\\d+(?:[,.]\\d+)?/) {|word| '' + word + ''}
But the problem is to only replace words in the text and leave the HTML as it is. So I guess it is a regex problem...
Thanks for any ideas.
I don't think a regexp is going to work for this - or, at least, it will always be brittle. A better way is to parse the page using Hpricot or Nokogiri, then go through it and modify the nodes that are plain text.
It sounds like you have it mostly planned out already.
Split the content into words and then for each word, create a link, such as whatever
EDIT (based on your comment):
Ahh ... I recommend you search around for screen scraping techniques. Most of them should start with removing anything between < and > characters, and replacing <br> and <p> with newlines.
I would use Nokogiri to remove the HTML structure before you use the regex.
no_html = Nokogiri::HTML(html_as_string).text
Simple. Hash the HTML, run your regex, then unhash the HTML.
<?php
class ht
{
static $hashes = array();
# hashes everything that matches $pattern and saves matches for later unhashing
function hash($text, $pattern) {
return preg_replace_callback($pattern, array(self,'push'), $text);
}
# hashes all html tags and saves them
function hash_html($html) {
return self::hash($html, '`<[^>]+>`');
}
# hashes and saves $value, returns key
function push($value) {
if(is_array($value)) $value = $value[0];
static $i = 0;
$key = "\x05".++$i."\x06";
self::$hashes[$key] = $value;
return $key;
}
# unhashes all saved values found in $text
function unhash($text) {
return str_replace(array_keys(self::$hashes), self::$hashes, $text);
}
function get($key) {
return self::$hashes[$key];
}
function clear() {
self::$hashes = array();
}
}
?>
Example usage:
ht::hash_html($your_html);
// your word->href converter here
ht::unhash($your_formatted_html);
Oh... right, I wrote this in PHP. Guess you'll have to convert it to ruby or js, but the idea is the same.